instruction stringlengths 71 71.9k |
|---|
I had a bit of an issue with my last piece of code, having to do with cleaning up resources. I needed a way to ensure the database connection was always properly closed, even if there still were instances of an IPresenter or IRepository still floating around.
IDisposable class module
Option Explicit
Public Sub Dispo... |
This is a "follow up" to an answer I gave on this question : Summing up distinct elements in steps
Here are the OP's requirements :
"My current task is to find a score from an array where the highest/lowest scores have been taken away, and if the highest/lowest occur more than once (ONLY if they occur more than once),... |
This is a wolfram language program I wrote for super-resolution, in this case meaning to guess at how to increase the the resolution, and so detail shown in a raster image such as a photograph.
It uses a similar but different aproach to its successor, which is much better program, so please start with the new aproach h... |
This is my second Custom Control I have made, a dice. The code below has worked 100% in all my tests, program contains 1 dice control and seven buttons, 6 for setting a number directly, and one for randomizing it. Feedback and improvement suggestions are greatly appreciated.
using System;
using System.Drawing;
using Sy... |
Is storing array values inside of a closure considered to be bad practice? I having been trying to decide if I should just use a standard object with key value pair. This is not the method I am using to populate arrays, but this does show how i create functions to store values.
Also, I'm wondering if this is technica... |
My goal was to create a tiny DOM builder library that made creating element trees less gross.
This is the syntax I decided on:
var foo = Builder.create('div', function(){
//set attributes
this.id = "foo-div";
this.title = "Foo Div";
//append a child node
this.create('button', function(){
/... |
I need a class to read and store directory structure. This is my first step in Objective C so I ask to you to say what you think.
Header file:
#import <Foundation/Foundation.h>
@interface FileStructureRepresentation : NSObject
- (id)initWithPath:(NSString *)path;
-(NSMutableDictionary*) parse;
@end
Code:
#import "F... |
override def get(key: String): Option[Any] = {
val timer = couchbaseMetricsTimer.time()
try { // Any way (is it more elegant?) to avoid the try/catch/finally?
Option(couchBaseClient.get(key))
} catch {
case e: Exception => couchbaseFailureMetricCounter.inc(); throw e
} finally {
timer.stop()
}
}
... |
Watson gives to Sherlock an array: A1, A2, ⋯, AN. He also gives to
Sherlock two other arrays: B1, B2, ⋯, BM and C1, C2, ⋯, CM. Then Watson asks
Sherlock to perform the following program:
for i = 1 to M do
for j = 1 to N do
if j % B[i] == 0 then
A[j] = A[j] * C[i]
endif
end do
end do
Can yo... |
I've written a custom PHP session class for handling sessions across the web app. Please review the code and point out mistakes and suggest better handling techniques.
require_once('config.php');
class Sessions {
protected $sessionID;
public function __construct(){
if( !isset($_SESSION) ){
$this->init_se... |
I have a method that is getting called when someone zooms camera on the map (Google map).
I recalculate the positions of markers of map and the code is clunky and not effective. I iterate over arrays three times per method call and that is really slow. When I have 600 markers the performance is really lacking.
What cou... |
Below's my attempt at creating a simple tab control in JavaScript and CSS, without making use of any libraries or frameworks.
Does this look OK to you guys? Can you see any obvious pitfalls? I believe this should work on all modern browsers, supporting as far back as IE9.
jsFiddle
<!DOCTYPE html>
<html>
<head>
<tit... |
I want to send an email just once per day. There is one button and any user can click that button. The email must not be sent twice. When the first user clicks the button, the email is sent. If some other user clicks the button, the email will not be sent again.
This is how I implemented, and it's working. There a... |
I have a Rails 3.2.14 app where I have a home controller (dashboard). In this controller and view I'm calling multiple instance variables to get different counts based off of scopes I've created in the Call and Unit model. I'd like to see if anyone has any suggestions on how I can DRY this up and query less so the co... |
I'm making a web application for a restaurant kind of type. The idea is to administrate the orders and customers with the functions such as:
Make a new order
Delete a order
View all the orders
Make a new customer
Delete a customer
View all the customers
Finance overview
I'm doing this by separate PHP files. Here's ... |
This is my factory class:
/// <summary>
/// Inject TextWriterFactory into the class you need to test
/// In the unit test, use SetWriter() to set a different TextWriter (ex: StringWriter)
/// Add extra overloads for Create method if needed
/// </summary>
public class TextWriterFactory {
private TextWriter _writer =... |
I need some kind of thin wrapper object to mark dictionary keys, like:
d = {
Required('name'): str,
Optional('age'): int,
}
And these wrappers should behave like the wrapped object (comparison, hashing, etc):
marked = Required('name')
marked == 'name' #-> True
d[marked] = 'hello'
d['name'] #-> 'hello'
With a si... |
How would you refactor this?
ExpensiveQuery must only run when necessary.
DECLARE @city VARCHAR(10)
DECLARE @status INT
IF @status = 5
BEGIN
SELECT c.Name, c.Phone
FROM Customers c
WHERE c.City = @city
AND c.Status = 5
END
ELSE IF @status = 10
BEGIN
SELECT c.Name, c.Phone
FROM Customers c
... |
After a lot of back and forth on various sites, reading articles, watching videos etc i still can not figure out the best way to secure my admin section.
The session id is regenerated every page reload / action to make session hijacking / fixation more difficult.
Let me know in the comments if you need any more details... |
The Domain
I have three types of items in my domain: ItemA, ItemB, ItemC. (I can't use their real names.) ItemA has one attribute: thing_id. ItemB has 6 attributes: thing_id, name, description, state_id, a_number, a_status. ItemC has 5 attributes: name, description, state_id, creator_id, category_id. There is some over... |
I wrote a program for DFS traversal, topological sort, find all vertices, and has_cycle methods.
Can you please suggest more elegant and eloquent ways for this program?
(Perhaps better ways to represent a graph with vertices and edges?)
NOTE: dfs and has_cycle implementation is inspired by the book "Algorithm Design Ma... |
I just finished a model class that represents an Instagram Networking client for my iOS app.
I am specifically looking for a review of my use of static constants. These are strings that represent notification names and notification userInfo dictionary keys.
Here is my networking class:
POPInstagramNetworkingClient.h:
... |
Considering I've got an exam on Spring tomorrow, I figured you could review a small example application I whipped together as preparation (and as such, I'd prefer the emphasis to be on Spring-related concepts).
Its functionality is straightforward: you start with a list of 3 games and you can edit or view its details,... |
How can I write this code better? I'm doing an animated magazine, so I run and then clean the animation per page.
magazine.turn({
width: MGZ_WIDTH,
height: MGZ_HEIGHT,
pages:MAGAZINE_PAGES,
display:DISPLAY_PAGE,
acceleration: !isChrome(),
... |
I built an easy inheritance implementation for JavScript that works similar to other OO languages and wanted some feedback on it. This works perfectly how I'd like it to, but I've read a lot of varying opinions about using __proto__ and was wondering if there's a better way to do this.
jsFiddle
/**
*
* Extensible Pro... |
I have a parent view which has a dblclick event handler bound to it. I also have a view which is a descendant of the parent. This child view has a click event handler bound to it.
Currently, my code works as intended, but looks like this:
var ParentView = Backbone.Marionette.ItemView.extend({
events: {
'dbl... |
I wrote a simple JavaScript tool to highlight multiple keywords at the same time in some text. It uses different color for each keyword, and also shows the count of matches.
I'm using Backbone.js with the following class structure:
App.Model: the main model, keeping track of:
the keywords
the words in the text and th... |
I thought it would be helpful to put together an example of what I'm talking about in the second part of my answer to this Stack Overflow question.
The idea is that there's some data that is updated very quickly (i.e. faster than the main queue can reasonably process blocks) on a background thread that needs to be disp... |
Introduction
Valve recently launched the Dota 2 Workshop Tools, which allows players to create their own maps with custom gamemodes, similar to Warcraft 3 in capabilities.
Ability and unit definitions are stored in txt files under a specific format, very similar to JSON:
{
"key" "value"
"otherKey" { //C-style c... |
Preamble: the default frame positioning with Swing JFrames has always bothered me. Eventually I wrote some code to calculate my available desktop space, not counting my abnormally-large right-side-anchored taskbar, and use that information to size and position my JFrames. Then I got sick of copy/pasting the same frame ... |
I implemented the following (what I believe to be) safe Reverse Polish Calculator.
Now I'm using foldM to take advantage of the power of Monads. Previously, I was not.
Can you please critique my code?
import Data.Maybe
import Text.Regex
import Control.Monad
import Network.CGI.Protocol
data Operator = Add | Subtract | ... |
I'm just getting into Clojure, and I wanted to make sure I am writing code the "Clojure way". The challenge I took on is Zeckendorf numbers (fairly trivial).
(defn fibs-until
([n]
(vec (if (< n 3)
(range 1 (inc n))
(concat [1 2] (fibs-until n 1 2)))))
([n a b]
(let [fib (+ a b)]
(if (> fib... |
I am implementing a mutable trie. I tested and it produces correct results. However, it is very slow. I benchmark it against plain old Data.Map, which is more than twice as fast.
Full source
So what am I doing wrong? I am expecting a fundamental flaw in the way I write mutable code here and not some micro performance t... |
This question is about an improvement of the code from this previous question (previous changed visibility, new applies a CSS class with a border).
It is a constructor function that attaches a click event to radio inputs using event delegation in order to add, remove CSS classes and enable the text input which contain... |
I don't like the logic to update [Repository] list here because I need to map whole list to change only specific field of specific node, I especially don't like that I need to provide all other fields in changing node alike (location x) etc... Major trouble there is that if I will edit data model I will be forced to e... |
Problem statement:
Calvin is driving his favorite vehicle on the 101 freeway. He notices that the check engine light of his vehicle is on, and he wants to service it immediately to avoid any risks. Luckily, a service lane runs parallel to the highway. The length of the highway and the service lane is N units. The serv... |
Problem Statement:
Manasa is out on a hike with friends. She finds a trail of stones with numbers on them. She starts following the trail and notices that two consecutive stones have a difference of either a or b. Legend has it that there is a treasure trove at the end of the trail and if Manasa can guess the value of... |
I have a vector with 10000 particles that I use in a Particle Filter. The problem is that it's taking too long to compute the weighted selection of the particles.
I want to use a vector of weights (probabilities) to select elements from a vector (particles) to generate a new vector (new_particles) with the same size as... |
I created a utility method ListUtils.partition(iterable, size) to partition a potentially large list to a list of smaller lists:
public class ListUtils {
public static <T> List<List<T>> partition(Iterable<T> iterable, int size) {
if (iterable == null) {
return Collections.emptyList();
}
... |
I am new with coding and I recently read an article about code refactoring, so I have made a console application for booking rooms on a ship. I need help with code refactoring. As far as I understand the refactoring, I think in my project there are only 2 parts where I need refactoring, which are as follows.
One is a b... |
I have created this program and it works fine. It's just that its too wonky and huge so I was wondering if anyone knew how I could shorten the program so I didn't have to put all of these into each button
if(guess == number){
l1.setText("You have won the number was " + number);
}
if(guess > number){
l1.setText... |
I'm aiming for the best and simplest way to access "global" variables set in the config file for my website. So I can use them anywhere, even inside functions
It's for file versioning, and I use htaccess to rewrite urls (trim out version part)
Right now, I'm at this:
// config.php:
class VERS {
static $css = '_214'... |
We have search results on our website and want to display different banners based on the search term entered. My solution for this is to check the URL for the search term since it is stored there, and then display the banner if there is a match.
As a result, I have about 20 conditions in an if statement and I think thi... |
In my code I have to login a user with username and password. But if the user sends his e-mail instead of his username, I have to resolve it with another request.
This is what the code looks like:
exports.auth = (request, response, next) ->
username = request.body.username
if request.body.email
users.findByEm... |
I wish to iterate through a Lua table, but want to get one particular element first always (its key is known beforehand).
Since the pairs function does not guarantee the order of a table's elements, I wrote a custom iterator function (I can insert every element into a indexed table and use the table.sort function, but ... |
I was recently talking to someone about a function I wrote to mimic (very basically) the string interpolation function String.Format() found in the C# language. They mentioned that I would have performance concerns using RegExp, and that I should try to parse the string template rune by rune. So I wrote a loop the best... |
I have written two methods that executes any type of HQL and returns data. Methods are like
public static Query getHqlQueryObject(String hql) throws Exception{
Query query = null;
Session session = null;
try {
session = HibernateUtil.getSessionFactory().getCurrentSession();
... |
I'd like to refactor my extractSimplePromptName test so it does the same but it's "prettier", hence less code. As far as looking at it, it seems like it could be refactored so it does the same thing, but it's just less code. I'm just fairly new to programming so having a hard time seeing where I should make the changes... |
I have a custom tableview cell for displaying different foods, with a star next to each name. If the food has been favorited (i.e., it exists in the database), the star is filled in, otherwise it is empty. I'm not sure if the logic that determines the color of the star should go in the view controller or the tableview... |
I ran into some issues with unit testing in that getting the response body etc from the curl handle was tricky. I didn't want to necessarily use a mock or abstract the curl functionality.
A colleague of mine suggested that I just use the localhost as an endpoint and reflect back the request for unit testing. I thought ... |
I'd like feedback on my function to convert FASTA data to a dictionary in Python. Here's an example of FASTA text:
>gi|33112219|sp|O93279.1|A4_TAKRU RecName: Full=Amyloid beta A4 protein; AltName: Full=ABPP; Short=APP; AltName: Full=Alzheimer disease amyloid A4 protein homolog; Contains: RecName: Full=Beta-amyloid prot... |
I am trying to extend the JSON format (for private use) to include an include statement. This could be used to include other .json files into a master file, for example.
#! /usr/bin/perl
use warnings;
use strict;
use File::Slurp 'read_file';
my $str=parseFile('t.json');
sub parseFile {
my ($fn)=@_;
my $str=read... |
I have some php code to style a button and activate it, when a specific variable is true.
It's actually a radio button, styled with the bootstrap to a button.
As you can see below, this is how it looks when the variable is '1'.
Also, the buttons at the bottom are the same, but then with one extra option.
The HTML code ... |
I've started to write a form data handler class in PHP. Can you please review it and point out any mistakes or logic errors, or perhaps if a method can be written in a better way?
define('VALIDATION_ERR', ' couldn`t be validated.');
define('REQUIRED_ERR', ' is required.');
define('PASSWORD_ERR', 'Password and Confirm P... |
The Authenticate method violates the command-query segregation principle, right? How can I adhere to the command-query segregation principle here?
public class Authenticator : IAuthenticator
{
public bool Authenticated
{
get { return HttpContext.Current.User.Identity.IsAuthenticated; }
}
public... |
For my first use of javascript I've made an app that takes an input verb from html in Japanese and outputs it in to many conjugated (manipulated) forms.
Essentially, it defines an alphabet, some initial arrays and functions for use, a function to initially check for values and interact with the html page, an object to... |
I've made a very simple slideshow that works by appending and prepending images (on click and every 3 seconds). This is my first time trying to use classes or objects so any help would be great. I feel this could be a little verbose so I'd love any sort of feedback.
The user can click through the slideshow, but it also... |
I'm writing a renderer to learn my way around OpenGL and right now I'm trying to understand how to sort the objects to be rendered. As I understand there are a few rules to this:
Sort to minimize state changes (like glUseProgram)
Sort solid objects from transparent objects
Sort the solid ones front to back, to decrea... |
I've written this DB Handler class. Please review it and suggest any code edits or point out mistakes and security loop holes. Please also suggest a better way to handle things, if there is a security loop hole in there.
class db {
protected $dbHost;
protected $dbUser;
protected $dbPass;
protected $dbName;
protected $... |
I'm new to AJAX and jQuery, and just for testing, I created this simple code. When the user enters their First Name and their Last Name it displays a message that says
Thanks for entering everything correctly!
in Bluish color, and when the user forgets to enter their First Name and their Last Name it displays an erro... |
I'm attempting to master LRU Caching. It must be thread safe, and it should preferably perform as well as web image-cache, (avg ~1MB).
Please take a look to see if there's anything wrong, amiss, etc.
ViewController.m (requesting the cache):
- (void)viewWillAppear:(BOOL)animated {
self.ricItems = [RicCache getCache... |
Recently a question was asked that solved a hackerrank problem: Counting gems amongst the rocks
The description of the challenge is:
John has discovered various rocks. Each rock is composed of various
elements, and each element is represented by a lowercase Latin letter
from 'a' to 'z'. An element can be present m... |
Below is an Android Activity and corresponding XML layout. The function of the class is to search an SQLite database to show results to the user.
Can I get a review of the code quality? This is my first Android app so feedback would be greatly appreciated as I do not know standard Android/Java practices to aim for.
Ac... |
I'm implementing a Web API that communicates with old WCF services and want to make it future proof.
The Web API consists of:
API controllers
Service Providers
Repositories
I've implemented a service and a repository layer. A repository factory is injected into each service, because services can communicate with more... |
I created an HTML5/JS tic-tac-toe game as an exercise and wanted some advice on my js code.
A couple of questions:
How can I improve the reset method? (currently reloads the page/re-initializes the game)
Anything advice on other improvements?
Live demo: http://jsfiddle.net/mbtt53tt/
tictactoe.html
<!DOCTYPE html>
<... |
I've got a situation where I have a list of Organizations (code to follow), and a user has a list of OrganizationIds (ints). I want to filter down the full list of Organizations using the User's OrganizationId list for a dropdown list. The query works, but it feels like there may be a more optimal way to write it. Is t... |
I met the RESTful ideology and I fell in love with it. However the only request methods supported by HTML forms so far are GET and POST, which is kind of sad, because this means that to use REST as it's supposed to be used I need to use some work around which is likely to not be pretty, as it really is.
So the only way... |
I'm in the process of writing a private messaging system and I have 2 URLs which go to the same view (is that bad?). The logic behind this madness relates to the way user relationships are structured in our system...
T
/ \___
C1 \
| C2
P1 / \
P2 P3
T = Trainer, C = C... |
I am trying to write an object "template" that use pImpl and MVC pattern to encapsulate everything not specific to the object. The following is how I tried to attempt it. I am sure that the code smells (if not stinks) but can't tell what's wrong with the design.
I would like to know what better alternatives with which ... |
I need to write a function that takes an original list of unique values and a resulting list:
[0,1,2,3]
[0,3,1,2]
and detect that only a single element was moved then report exactly what was moved where. If the resulting list is not the result of moving exactly one item from source to destination, this code should fai... |
With a table based interface where users can update the rows by pressing a button. Perhaps there is a better way of doing this, without pressing a button, i.e. post on textarea/row change (could be a selectbox column). My requirement is that it's the LEAST amount of JavaScript possible, without being cryptic.
For examp... |
I have a section of my code that seems to take a while during processing. Basically rawArray contains ~1.5 million rows and tempArray has around 1000 rows. I can see why it's slow as for each of the 1.5 million rows it has to loop through the tempArray and look for a match. Any hints for optimising this would be great!... |
I modified the implementation from this website to include a salt:
package de.xxx.yyy.main;
import static org.junit.Assert.*;
import org.bouncycastle.crypto.BlockCipher;
import org.bouncycastle.crypto.BufferedBlockCipher;
import org.bouncycastle.crypto.DataLengthException;
import org.bouncycastle.crypto.InvalidCipher... |
Can the display function be re-written to avoid duplication of the std::for_each loop?
#include <iostream>
#include <set>
#include <algorithm>
struct Widget
{
int id;
Widget(int i) : id(i){}
};
namespace std
{
template<>
struct less<Widget *> {
public:
bool operator ()(Widget *const& a, Wi... |
I have written a JavaScript function that takes JSON encoded data and then, with conditionals, formats that data into a table.
I asked this question not so long ago but that was just a snippet of this:
Better way to code these deeply nested / multiple if/else statements
This is the full thing with all the structure and... |
I have a pretty unusual situation (please, don't ask why) where I need to compare objects which might be a string or double to string which might be a string or a double.ToString(). I've come up with something which I really don't like, so please feel free to criticize it and suggest a better solution.
public bool AreE... |
Riddle Description:
\$N\$ doors are closed. In the first pass, I open all of them. In the
second pass, I toggle every second door. In the third pass, I toggle
every third door. I continue this until I have completed the \$N\$th
pass. Find all the doors that will remain open after \$N\$ passes.
public static voi... |
So I have the following code that takes the input of two arrays, and apply some queries to match elements from DBpediaClassesArray with elements from YagoClassesArray, then it returns the number of elements that are similar in the two ArrayLists.
public static void get_ND_Matches() throws IOException{
@Suppress... |
Often I have to write classes implementing listener interfaces with empty methods bodies.
For example:
MyOnClickListener .java
public interface MyOnClickListener {
void onClick();
}
and
MyDummyOnClickListener .java
public class MyDummyOnClickListener implements MyOnClickListener {
public void onClick() {
... |
I have the following code, but I'm looking for a way to make the code read easier.
public void synchronizePageAndExcecuteVerifyNode() throws Exception {
String nameTestcase = this.getClass().getSimpleName();
WriteTo.testgoal(nameTestcase, TestgoalState.nvt, "");
Boolean testDataGenerated = eventTestData.ev... |
I'm new to SQL and working on a monthly change calculation. I want to calculate the change between this months balance and the previous months balance.
This query is working for me but does not feel like the best syntax. Do you think this is fine, or are there any suggestions?
SELECT
ROW_NUMBER() OVER(ORDER ... |
I have written a Query String Parser to Parse a given query string. Is there any enhancement I can do?
/**
* Class QueryStringParser is used to parse Query String and to get value(s) of
* the given parameter key.
*
* @author TapasB
*/
public class QueryStringParser {
private static class NameValuePair {
... |
I am making a simple jQuery code that changes the content of a static HTML page when a button (previous/next aka left/right) are pressed. The page is static, so the content that must be cycled (images setted as background, descriptions and a link) are saved in an array. Images must be shown two at a time, so the arrays... |
I'm reading through Write Yourself a Scheme after finishing going through Learn You a Haskell. I attempted one of the early exercises: writing a program to get an operator and two numbers and do a computation. It works fine.
Things I would like to know:
How should I structure a program, in terms of building larger func... |
I have written a Python 2.6.6 script in order to make tables by taking the third column of every text file in a particular subgroup (signal and background in this case[particle physics]). However, I used the exec command too often and I think this code can be written more elegantly.
#!/usr/bin/python
import sys
stringp... |
I want to generate a list of N different random numbers:
public static List<int> GetRandomNumbers(int count)
{
List<int> randomNumbers = new List<int>();
for (int i=0; i<count; i++)
{
int number;
do number = random.Next();
while (randomNumbers.Contains(number));
rand... |
My goal is to have something really simple with as small an amount of code as possible. The real code is used to parse a text file of nested structures. This code is highly simplified but is the general way that the state machine would work.
Is there a replacement for the global?
# python doesn't support enums but can... |
I am following the Golang tour and I have been asked to build a couple of functions to manipulate binary trees.
My code runs as expected, but I would like to know if I could further improve my code. I'm looking for improvements regarding the algorithm and mainly the use of go routines. As the point of this exercise is ... |
I have the below function that works and cycles through 3 possible levels. Is there a way to do the same as the function below but not have to do the multiple foreach statements, and not have to specify the number of levels as it is dynamic?
Basically the responses list can contain multiple GroupResponseTypes each of t... |
I made a value comparison "programming language" similar to a previous one I made, except this one is based solely on value comparisons.
# Basic value comparison
from operator import *
# Main compare class
class Compare(object):
def __init__(self):
self.OpError = "OpError: Invalid operator or brace.\n"
... |
I'm investigating Go for use in our internal network / office project management system, and need a way to check and edit the color tags that you can set in Finder on files or folders (extended attributes, xattrs). This is my first Go code. Is this a reasonable way to go about it, and is the interface something that ... |
This problem is identical to the one here:
Suppose that you have been assigned the job of buying the plumbing
pipes for a construction project. Your foreman gives you a list of the
varying lengths of pipe needed, but the distributor sells stock pipe
only in one fixed size. You can, however, cut each stock pipe i... |
I need to fix and maintain the master volume in PulseAudio (so that I don't blow up my speakers). E.g. call gfaaudio -v 25 to fix volume at 25%. Is there a cleaner way to get this done?
gfaaudio:
#!/bin/bash
usage="Usage: `basename $0` [-v VOL] "
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
echo $usage
ec... |
I use Nginx as a server, and I currently use this for configuration of each my sites. Basically, I have multiple files like this located in /etc/nginx/conf.d/.
#example.conf
server {
listen 80;
server_name www.my-site.com my-site.com;
root /var/www/html/my-site.com;
location /... |
I have been using this function locally to encrypt strings for example a username.
If the user successfully logged in, place the encrypted username into a session, decrypt the username in the admin section and use for various things.
Is it a strong method and are there any security concerns with the way I'm using it?
... |
I'm working on medium sized desktop application (with around 100 tables in database). For persistence layer I decided to use Hibernate for the first time to avoid massive redundancy of code for persistence layer.
This is final implementation of DAO interfaces:
public class BaseDAOImpl<E extends Serializable> implements... |
I'm writing an application that will use the JLayer library to play an mp3 file. Since the player does not have any methods to pause the playback - play() does not return until the song is finished - I decided to put it in a thread and simply control that thread. This is possible because one can execute play(1) which p... |
I want to make a query to order by the IN clause items. I read from another thread that I can use ORDER BY FIELD(a.id, val1,val2......) When binding values to parameters for two occurrences of $in, I ended up using two foreach loops:
foreach ($tid as $t) {
$users->bindValue($c++, $t);
... |
I'll start with giving a bit of background as there are many classes involved and I can't attach all of them because that would make this question wildly too long. For the curios they can be found at my github repo.
I have an immutable structure called a Chassis which consists of 8 immutable Components. Each Component ... |
I was hacking around this morning and wanting to use automatically generate safe-to-use variables from $_POST. Probably not the best use of extract() and compact(), but extract() allowed me to prefix variable names and compact(explode()) seemed like a neat way to stick everything back into an array after being prefixed... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.