instruction stringlengths 71 71.9k |
|---|
I am calling a C library via P/Invoke. That library needs to be called in sucession with an increasing unsigned int, and returns a pointer. That pointer is then mapped to a managed type, until it returns a NULL pointer.
In C, the idiomatic way to write it, is probably for(i=0;;i++), but what is the most idiomatic way ... |
This module is dependent upon a utility module I previously posted:
General feedback on utility module
I'm looking for general feedback on how to make this useful to other people. This is a subset of jQuery with some additions, and what I feel are improvements.
The code passes jslint and minifies well with closure.
/**... |
This is my table model code style:
public class MyModel extends DefaultTableModel {
static Vector data = new Vector();
static Vector column = new Vector();
Connection conn;
Statement statement;
ResultSet result;
public MyModel() {
super(data, column);
try {
conn = DriverManager.getConnection(...);
statement =... |
I am implementing an IEqualityComparer for Dictionary objects and am looking for input on a couple of different approaches. I define equality in this case to be that both dictionaries contain the same set of KeyValuePair's as defined by equality of the hash value for the respective keys and values.
The first generates ... |
I'm rewriting an old Swing project that I did a few months ago, a fairly simple copy-cat of MS paint. I've been doing a pretty good job of keeping the code maintainable and organized, but I've hit a wall on one class. All I need is some general tips on organization on this one class.
The way I have my program set up is... |
I got about 4 days of assembly knowledge, so I need a review on this strcpy function and if it can be done better (at least I have the feeling).
Full code (with the test included):
.data
s:
.asciz "Hello world!"
.bss
.lcomm destination, 4
.text
.globl main
main:
nop
pushl $s
pushl $destin... |
I would like to share my design of mvc via js.
What do you think about it? I tried to not use any mvc framework but i want to get clear structure and a decoupled organisation.
Next step for me is evaluating something like require.js to get rid of the ordering within the index file
The code:
XX.namespace.ContactListCont... |
This is my first JavaScript/jQuery project after having been reading and learning for a good few weeks. I am proud I have made something that at least works. However, I'm sure that my code is inefficient, and possibly more complex that it needs to be. I would appreciate any feedback on my JavaScript. What other ways wo... |
I have an SQL Server table from which I want to extract data from one column (DD) and return as multiple columns.
The data is in NVARCHAR and looks like:
;<b>HF</b>:GN;<b>HM</b>:GTN;<b>HN</b>:GN;<b>PN</b>:AN;<b>PVD</b>:GO;<b>PVR</b>:1.1;<b>BN</b>:AN;<b>BVD</b>:GO;<b>BV</b>:2.3;
There is less to be changed in the way ... |
I have the following model:
namespace Site.Models.Country
{
public class Country
{
public string CountryCode { get; set; }
public string CountryName { get; set; }
public string CountryUrl { get; set; }
}
}
In a separate model folder for a different view and controller, I have a diff... |
There are my shapes (for example):
public abstract class Shape
{
protected int _id;
protected string _description;
public abstract string ToXml();
}
public sealed class Triangle : Shape
{
public int TriangleId { get { return _id; } set { _id = value; } }
public string TriangleDescription { get { return _des... |
The code inputs an int, n, which is the number of lines to follow. Then, on each line, the first number goes to array A, the second to B, and the third to C. I then pass these 4 arguments to sub which I have no control over (in an object file where I don't know the implementation). All I know is that it returns an int.... |
I'm being forced to use the common anti-pattern of a public interface Constants which many classes in this project implement. Long story short, I need to have a List constant which is pre-populated with values. Normally I would do this like so:
public static final List<String> MY_CONSTANT = new ArrayList<String>();
s... |
I've implemented a Ruby version of Conway's Game of Life that functions correctly and passes all my tests. I was hoping to get some advice on how I could clean up the code for readability and efficiency.
For anyone who doesn't know the rule to the Game of life, they are as follows:
Any live cell with fewer than two ... |
I wrote up a simple averages calculator for student grades, based on this daily programming challenge.
First, the script asks for the file name for the text file containing the student names and grades. It is formatted like so:
JON 19 14 15 15 16
JEREMY 15 11 10 15 16
JESSE 19 17 20 19 18
The user is then asked how ma... |
I haven't understood how I can perform (and so prevent ) a Directory traversal attack thorugh php.
Probably isn't necessary, but I ask: my script contains a multiple file upload and download, this is the script to upload:
if (isset($setting[5]) && $setting[5] == 1) {
$msid = $DBH->lastInsertId();
if (isset($_FI... |
I have the following controller function. What I want to do is make this function do less. Most of this code is just random checks on various things that is also done on most of my other controllers. So to prevent from consistently copying and pasting this code THAT IS NOT where the access_level_id is checked in the if... |
I'm working with knockout and am trying to stay true the MVVM structure and trying to make the objects have that dependency on each other.
Model, ViewModel, Service definitions:
var App = window.App || {};
(function(ns, $, ko) {
ns.Models = {};
ns.ViewModels = {};
ns.Services = ns.Services || {};
//Se... |
I come today with a state machine I'm currently working on.
Problem:
Given any State that the Character is in, a button press or combination of button presses can modify that state in a different way than how the initial state was entered.
I've looked at several different methods of creating a solution, but I feel th... |
I'm designing a security camera program. Right now, I am just trying to set up the GUI before receiving. I am using Kivy since, in the future, I plan on designing some programs for Android. I really like Python, and I figured I'd start learning Kivy.
My question is: am I building the GUI structure correctly?
The layo... |
I've just launched my first project on GitHub. It's a jQuery plugin that helps create a responsive menu. It deals with interactivity (essentially using toggle and some classes), and leaves all the presentation stuff for CSS.
Here is the basics for using the plugin:
First, create the structure with HTML:
<div id="conte... |
What might be wrong with this shared pointer? One good point of it might be, that it should handle array types correctly by default (e.g. light_ptr<int[]>(new int[10]).
std::shared_ptr has the advantage of being more portable. For example, emscripten provides an implementation, but light_ptr won't compile, still, it ca... |
I'm new to programming, and I would like to know if this is the right way to layout code. If anyone has any tips, please share them.
import random
import time
def displayIntro():
print("You are in a land full of dragons. In front of")
print("you are two caves. In one cave the dragon is")
print("friendly an... |
This first stores a string as input, loops through it to extract all of the numbers into an ArrayList, then prints all of these numbers along with their sum and product.
How would I decompose this Java program into multiple methods?
public class Assignment1 {
public static void main(String[] args){
// Cre... |
I am trying to write a count sort in Python to beat the built-in timsort in certain situations. Right now it beats the built-in sorted function, but only for very large arrays (1 million integers in length and longer, I haven't tried over 10 million) and only for a range no larger than 10,000. Additionally, the victory... |
I put together a Custom Linked List class in hopes of using it for a Talent/Skill Tree for a game. It allows for inserting nodes with NSMutableDictionary for Skills and Requirements along with a nodeID and a Boolean to see if said node is activated or not.
I would like some feedback on this and any comments/ideas (all... |
This changes the application's volume through the Trackbar (1-100, 1% to 100%):
public static class NativeMethods
{
//Winm WindowsSound
[DllImport("winmm.dll")]
internal static extern int waveOutGetVolume(IntPtr hwo, out uint dwVolume);
[DllImport("winmm.dll")]
internal static extern int waveOutSetV... |
This is a very simple anagram game that plays only with names of colors.
I tried to focus on code design. I also wanted it to support further updates. But, my init seems smelly and you will notice it, especially in the main loop.
I was wondering about my naming and commenting/docstrings. I need strong criticism here... |
I have been attempting to write a code that converts Prefix expressions to Postfix expressions.
So far here's what I have made (note that I am new and hence it may not be efficient!)
/***************************************************
NOTE: This code fails to realise the precedence
of parentheses and $ (exponent... |
The problem is here, the solutions are here. I don't see a solution like mine (maybe the 4th), it seems to work though.
-- ---------------------------
-- 18 (**) Extract a slice from a list (idx start from 1)
slice _ _ 0 = []
slice (x:xs) 1 k = x : slice xs 1 (k-1)
slice (x:xs) i k = slice xs (i-1) (k-1)
I tried... |
Here is my solution for this stackoverflow question.
It is designed to return an onbeforeunload message when the user leaves the page (excluding postbacks). It does this by logging a timestamp each time a .NET control causes a postback (either full or partial using update panels). When this happens, if allowedWaitTime ... |
Which is the best practice in getting data from repository? passing just by object or by Id?
public IQueryable<Attendance> GetByPersonId(int id)
{
return DbSet.Where(ps => ps.PersonId == id);
}
or
public IQueryable<Attendance> GetByPerson(Person person)
{
return DbSet.Where(ps => ps.Person... |
I'd like to improve my code, but I'm not sure where to start. Everything works as I want it to; I just think it's ugly.
I'll split this into two parts:
I have two drop-downs that I'll explain later. In these drop-downs, I have options to set currency and language. I use a hidden form to set the current values with PH... |
So far I've implemented a way to add to my RedBlackTree (will be used with A* pathfinding - hence the F value). I'm not entirely sure how to improve it further.
I want to add a remove function to this tree, but can't find anything online that suits my style of tree. Any help? I only need to delete the first node. Als... |
I'd like this code reviewed.
import java.util.NoSuchElementException;
public class MergeSort {
private Node first;
private Node last;
private static class Node {
int element;
Node next;
Node(int element, Node node) {
this.element = element;
this.next = no... |
I have a jQuery "checkbox checked/unchecked" function that works well. This is a checkbox for turning a particular URL parameter on or off. But I believe this code could be written a lot tighter. Does anyone have any suggestions?
$('#mapControl').live('click', function(){
var thisUrl = $(location).attr('href');
if($(... |
So, I'm diving into C and decided to create cons cells. I'd like some thoughts on style and correctness. There are no warnings with -Wall -g and Valgrind doesn't complain about anything.
I'm really not sure what to do when the list is NULL in the first function.
#include <stdio.h>
#include <stdlib.h>
struct Cell {
... |
I wrote this little program, but I'm not sure if it's properly written. Actually, it can't handle leap years (every year is 365 days long) and you have to write the earlier date before. It seems to be working correctly.
Can you tell me if it's okay or not, and what should I change in it to make it good?
#include <iost... |
In the effort to improve my C knowledge, I tried creating a wildcard search function:
bool wildcard(char *value, char *wcard) {
size_t vsize = strlen(value);
size_t wsize = strlen(wcard);
bool no_match = false;
if (wsize > vsize) {
return false;
}
for (int w = 0, v = 0; w < wsize; w++... |
I have implemented the following code:
class A
{
abstract void f1(Object obj, Object data);
}
class A1:A
{
void f1(Object obj, Object data)
{
m1(obj,data);
}
void m1(Object obj, Object data)
{
}
}
class A2:A
{
void f1(Object obj, Object data)
{
m2(obj, data);
}... |
Are there any issues in this code?
/// <summary>
/// This function gets the unique identifier of a member by the given
/// login user name of that member on our web site.
/// </summary>
/// <param name="userName">The username</param>
public static string GetMemberNumberByUserId(string userName, string connectionString)... |
I want to get the filename and last 23 characters when I drag into a textbox.
I have it working, but I would like to just have one line. Currently, I think I am doing a bit of a workaround. As I must use a string array, and I only want one string, so I don't really need an array.
private void First_DragDrop(object sen... |
This is an implementation of a trie, that I will be using on a code editor to parse keywords from a given programming language. I decided to use a trie when I asked this question, and the implementation seems to perform pretty well and without errors from valgrind/memcheck.
I want to make sure I'm squeezing every bit o... |
I've been told that my code is horribly-written. It works exactly the way I want it to, but I have been told that it needs to be safer and more efficient.
Here's the code.
Here's the main PHP script:
<?php
$host = "*******"; // Host firstname
$name = "*******"; // Mysql userfirstname
$password = "*******!"; //... |
I've got a CSV that contains users and permissions in the below format, where users can have as little as one or as many as eight different permissions:
USER,PERM1,PERM2,PERM3,PERM4,PERM5,PERM6,PERM7,PERM8
jdoe,perm1,perm2
tsmith,perm1,perm2,perm3,perm4,perm5,perm6,perm7,perm8
This is the desired format, with each uni... |
For the following problem statement, I design following classes. Can you please tell me if this is the correct implementation or if there can be a better one?
Let's say there is call center with three levels of employees: fresher, technical lead (TL), product manager (PM). There can be multiple employees, but only one... |
How might I refactor this to get rid of all the if-else?
def self.dispatches_for(object)
scope = Dispatch.asc(:days)
if object.class == Habit
scope.where(:habit=>object).map{|d|d}
elsif object.class == User
scope.where(:coach=>object).map{|d|d}
elsif object.class == Content
scope.whe... |
I am new to C, so I have been trying to get practice doing some coding.
Usually I use languages like Java, python, ruby, etc: Garbage collected languages. So manually cleaning up is new to me and I would appreciate any advice on whether there are major flaws in my approach.
Also any other comments on the overall idomat... |
I have implemented a recursive O(n log n) algorithm for solving the maximum sub-array problem. I would like a general review for it.
Here the max_subarray is the main function, and the static one is the auxillary function for it.
#include<stdio.h>
int max_subarray(int array[], int *low, int *high);
static int max_cro... |
I implemented an iterative \$O(n)\$ algorithm for solving the maximum sub-array problem. I would like a general review for it.
Here the max_subarray is the main function and the ones which are static are auxiliary functions for it.
#include<stdio.h>
int max_subarray(int array[], int *low, int *high);
static void init... |
I have an accordion that checks if there is data to be displayed and if so, the accordion show the data from the specific month.
Is there a way to simplify the code below?
<?php
$conn = mysql_connect("localhost","user","pass");
mysql_select_db("lista_de_analize");
mysql_set_charset("UTF8", $conn);
?>
<scrip... |
I'd like feedback on my callbacks/promises alternative, please.
The yld repository
var yld;
yld = (function () {
'use strict';
var slice, clearer, defer, prepare, yld;
slice = Array.prototype.slice;
clearer = {
yld: {
value: undefined
},
throw: {
value: undefined
}
};
Object.freeze(... |
I've been reading the security issue on logging out from a website system written in PHP, using sessions.
My current code is:
session_start();
if (isset($_SESSION["logged_in"])) {
unset($_SESSION["logged_in"]);
unset($_SESSION["ss_fprint"]);
unset($_SESSION["alive"]);
session_destroy();
session_reg... |
I've tried implementing priority queue with fixed size in Java using TreeSet and overriding add() method:
public class FixedSizePriorityQueue<E> extends TreeSet<E> {
private final int capacity;
public FixedSizePriorityQueue(final int capacity) {
this.capacity = capacity;
}
public FixedSizePrio... |
I wrote this little code in c++. It calculates the needed time for a given speed of a medium (for example the speed is 1024 B/s, the file size is 1MB, it'll take 17 minutes and 4 seconds to finish). The code works, but I'm not sure if it's proper.
Can you tell me if it's okay or not?
#include <iostream>
int main()
{
... |
For a project I need to replicate a website and I was wondering if any of you could take a quick look to see if I made any obvious mistakes. Right now it's just the HTML part, but I would like to make sure everything is correct in the HTML part before I move on to the CSS. Picture added below. Thanks in advance!
<!DOC... |
I've written a GM script to filter some results from Experteer.com results: specifically, many of the rows are "only for Premium members" and don't allow you to click through or see details, so I've written the script to hide those results from cluttering the display.
I'm very much a newbie to JavaScript and cobbled t... |
I have 2 nested resources in one of my Rails apps and the way the index is handled by the inner resources bothers me somewhat:
def index
@program = Program.approved.find(params[:program_id]) if params[:program_id]
if params[:tags]
tags = params[:tags].split(" ")
if @program
@sites = Site.whe... |
This is my implementation based on Map<K,V> interface. The BST is a linked binary tree with root reference, both internal and external nodes (MyBSNode) contains (key, value) entries
What do you think? There's something to improve?
public BSPosition<E> insert(int k, E e) {
if(isEmpty()){
/* Sets root */
... |
I wrote this converter code. It can convert a number from 1-100 into words. It works perfectly, but it seems to be too complicated to me.
Can you tell me whether it's okay or not?
#include <iostream>
int main()
{
int number;
int first_digit;
int second_digit;
std::cout << "Enter the number: ";
st... |
I'm a bit clumsy at writing JavaScript. I have some nice code like this:
(function($){
$.fn.forceNumeric = function(){
return this.each(function(){
$(this).keyup(function(){
if (!/^[0-9]+$/.test($(this).val())){
$(this).val($(this).val().replace(/[^0-9]/g, ''... |
I'm wondering how I could improve my list's element-adding speed or just the whole list implementation.
The adding function first checks if the object is unique. If not, it will just check if the new data is better (the lower the value, the better) than the old one, then swap the values or just skip adding an element.
... |
I am learning C and tried to make a basic singly linked list. I am looking for some feedback on my implementation. I have implemented deletion and reversal functions. Be hard on me as I am trying to improve.
#include <stdio.h>
#include <stdlib.h>
//very basic linked list implimentation in C.
//basic node structure. N... |
Any reviews/ways to speed up/general improvements for my Merge Sort? Maybe something to simplify it or add more to it?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace prjT02L08_Predator_Prey
{
abstract class MergeSort
{
public static List<Node> Sort(List<... |
I wrote this pretty simple program (it's an exercise from a book). It counts the words in a simple string. The book is a very old one (I think it's from 2003) and uses char arrays. Because of this, I don't know if this solution is a proper one or not.
Can you tell me whether it is okay or not?
#include <iostream>
int... |
I have around 150 lines of code that I managed to optimize.
But, because my two methods and the six if-statements almost are identical, could there be room for improvement? Maybe it could be done with only one button and one listbox?
As I'm out of ideas and could learn more myself, I'd like to know what could be done... |
I am an average coder trying to improve my Python by doing solved problems in it.
One of the problem I did is this, here is the code I tried which
I have based on the official solution:
def area(A, B, C):
return float((x[B] - x[A])*(y[C] - y[B]) - (y[B] - y[A])*(x[C] -x[B]))/2
x, y = {}, {}
n = int(raw_input())
for i... |
Consider this code where I read an input file with 6 columns (0-5):
Initialize a variable history_ends to 5000.
When the column0 value (i.e. job[0] < 5000) I add 5000 lines of the input file in a list (historyjobs) else the rest of the lines until the eof in another list (targetjobs).
All the historyjobs list all cont... |
I'm trying to get my head around asyncronous programming in node.js.
My example is reading all the files from a directory.
I know I can avoid asyncronous programming by using the syncronous methods:
var fs = require('fs');
names = fs.readdirSync(".");
for(i in names) {
fileinfo = fs.statSync( names[i] );
if( filei... |
I am using this as a learning exercise primarily and want to ensure my code is optimal. The main thing is that it is reliable and I am made aware of any flaws.
Could it be made more efficient or more readable? How about style?
I thought about returning a char*, but then the caller would have to think to deallocate th... |
I have been doing some JS lately and I would like to get some constructive criticism.
The project I am working on
var SpotifiedList = [],
youtubeSongs, spotifySongs = 0,
spotifiedSongs = 0,
playNext;
$(document).ready(function () {
var id = window.location.hash;
if (id) {
$("#playlistID").val(id.substring(1));... |
I have a very simple code that allows me to keep track of what the user inserts in a raw_input.
The kind of controls I check are if the user inserts "f" the program is finished or if the user inserts nothing, the program keeps on running remembering all the inputs the user has inserted.
It works but I think it's very u... |
This program prints out a 10x10 square and uses only bit operations. It works well, but I don't like that global array.
Can you tell me if the code is proper or not?
#include <iostream>
const std::size_t HEIGHT = 10;
const std::size_t WIDTH = 10;
char graphics[WIDTH/8][HEIGHT];
inline void set_bit(std::size_t x, st... |
I've got information that is imported from a CSV file that my site grabs every day with PHP. I'm just learning RegEx so I'm able to do what I need to do but am looking to get more efficient with my coding.
Some of example of the kinds of strings that would come in would be:
15 SE NORFOLK
5 NNE OAKLAND
1 S LOS ANGELES
1... |
public static Integer[] eliminateDuplicate(int[] a) {
if (a == null) {
throw new NullPointerException();
}
List<Integer> list = new ArrayList<Integer>();
for (int i = 0; i < a.length; i++) {
// include last element by default, if not the last element, do the ch... |
It's an exercise from a book. There is a given long integer that I should convert into 8 4-bit values. The exercise is not very clear for me, but I think I understood the task correctly.
I googled how to return with an array in a function. In the splitter function I add the last 4 bits into the values array, then cut... |
I am trying to parse this XML file. I have the extension and I need to get the description, icon, and class from the XML. My code works(ish) (I know how to continue from where I am), but it doesn't seem very elegant. Is there a better way of doing this?
Here is the PHP code:
<?php
if($xml = simplexml_load_file('formats... |
I have recently started code kata and learning for myself, as I would like to
learn test-first development. I have started doing a shopping cart as my code kata. I have included a test as well. I would like to know what are the ways I could improve my below code. I know I need to use dependency injection next step. ... |
I'm working my way through The Java Programming Language, 4th edition. This is exercise 2.2:
Write a LinkedList class that has a field of type Object and a reference to the next LinkedList element in the list.
Is this an adequate solution? Is there a more efficient way to build up a test list for this example?
class... |
I am coding a Hanning filter which is a recursive relation:
y[i] = 0.25*(x[i] + 2*x[i-1] + x[i-2])
And here is my code were I attempt to unroll 3 times:
public void HanningFilter(float[] array) {
int len = array.length;
int i;
for (i = 2; i < len-3; i+=3) {
array[i] = 0.25f*(arra... |
Nearly time to hand this project in, and I want it to be as close to perfect as possible. So, any issue (no matter how small) - let me know. If you have any ideas that would improve the efficiency or readability of my code (e.g. delegates), let me know.
I am already aware that I should use camelCase for variables and P... |
I want to make a graph from input from a text file in the format:
vertex1 vertex2 cost time
where vertex1 and vertex2 are strings that form an edge and cost and time are the properties of that edge. This information will be used to construct the Graph based on cost. I want to plan out the project before coding it so ... |
I am reading the book Clean Code by Rob Martin and am trying to write the cleanest possible code.
I wrote this script as part of my project. Could you please criticise it and let me know how it could be improved?
/**
* File Downloading, Unzipping and extracting Content - PHP
*
* Usage:
*
* $fileImporter = new F... |
class PropFinal(CrawlSpider):
name = "propfinal"
allowed_domains = [over 200 allowed domains here]
start_urls = ["http://www.putnam-fl.com/coc/index.php?option=com_content&view=article&id=385&Itemid=114"
]
def __init__(self, *args, **kwargs):
##Is there a better way to add all 200 or... |
This is my first attempt at Quick Sort and am looking for some helpful criticisms on how I can make my code better. Thank you
def manSort(self, unSorted):
if len(unSorted) <= 1:
return unSorted
else:
greater = []
less = []
pivots = unSorted[len(unSorted)/2]
pivotPlace = [... |
I'd like to extract HTML content of websites and save it into a file. To achieve this, I have the following (working) code:
output = codecs.open("test.html", "a", "utf-8")
def first():
for i in range(1, 10):
root = lxml.html.parse('http://test'+str(i)+'.xyz'+'?action=source').getroot()
for empty ... |
Please review my code to help improve its quality.
public void printHeadOfNonIntersectingLinkedList(List<Standalone> listStandalones) {
final Map<Node, Node> tailHeads = new HashMap<Node, Node>();
for (Standalone ll : listStandalones) {
Node temp = ll.first;
while (temp.next != null) {
... |
I am a newbie to C. I've just wrote a linked list program, compiled it, and received a segmentation error. I have no clue where it went wrong. Can somebody help me?
# include <stdio.h>
#include <stdlib.h>
struct snode{
struct snode *next;
int val;
};
struct slist{
struct snode *head;
struct snode *tail;
i... |
I have been looking around for a good place to get my code reviewed for some time. I just stumbled on this site and I was hoping some people could tell me if I'm progressing in the right direction. This is a snippet from a sudoku game I'm making. The full source code can be viewed at http://www.lesshardtofind.com/Su... |
I'm currently learning programming for the first time and I've created the following implementation of quick sort in C#. I basically read a very basic overview of how quick sort works recursively and implemented it without looking at any concrete examples of its implementation so that I could learn the most from it.
Co... |
I have a VenuesController and an EventsController. My venues controller has an admin_add method that, well, allows an administrator to add a venue to the database. It looks like this:
public function admin_add() {
if ($this->request->is('post')) {
if ($this->Venue->save($this->request->data)) {
... |
I am making a GWT application and have to prevent client code from using null values in collections.
I found an answer but GWT doesn't support Queue and its implementations as the GWT documentation says.
So, I had to make my own implementation.
import java.io.Serializable;
import java.util.ArrayList;
import java.util.C... |
I have a PDO class below:
class DB {
private $dbh;
private $stmt;
static $db_type;
static $connections;
public function __construct($db, $id="") {
switch($db) {
case "db1":
try{
$this->dbh = new PDO... |
I use a worker thread for some data processing in my MFC project. In the thread-controlling function, it needs to use some parameters (declared as member variables) to the data-processing. I use a sub-dialog (which is triggered by a menu item and contains a few edit controls) to change the values of the parameters, tha... |
I am trying to display the leave history of a particular employee. But, when I choose a particular month (for example, I choose to display January instead of displaying the history of January), it displays all the history from this year. Is there anything wrong with my code?
<?php
echo 'View the application history b... |
Recently, I've noticed that my code looks so ugly because there were a bunch of functions and global variables. So, I started reading a little bit about design patterns. Now I come with something that's working for me, but I am not sure if it's good practice.
Anyway, I would like you to take a look at the code and tel... |
I'm fairly new at JavaScript, and I'm finding that JS is a language with what seems like an unusually high number of gotchas for the inexperienced, so some criticisms of this code would be particularly appreciated.
The function getProperties below is a relatively simple function that returns an array of the names (not ... |
The following is a code to detect a loop in a linked list. This question is prepared strictly for interview purposes. This code has been modeled as per Linkedlist.java
How should I decide if a function like hasLoop() should be included as an instance method or should be a static method similar to sort in Collections.j... |
I posted this question over at Stackoverflow, which was off-topic.
I was using ObservableCollection in a number of places in my WPF application for very large arrays. This caused a problem as ObservableCollection did not take an argument for capacity like List did. This was an important optimization for locking down m... |
I have a rather clunky function that returns a number based on certain values:
local = {'abs154': '4'}
w12,sv2,sv4,sv6,sv8,sv10,sv12=75,95,110,104,101,110,116
supers = [["5", w12], ["6", w12], ["7", w12], ["8", w12], ["16", w12], ["17", w12], ["18", w12], ["9", sv2], ["11", sv2], ["12", sv2], ["13", sv2], ["14", sv2]... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.