instruction stringlengths 71 39k |
|---|
I'm not a C programmer, just wanted to make a fast solution to the problem.
Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner.
How many such routes are there through a 20×20 grid?
Here's my code:
#include <stdio.h... |
This is used to display an accordion with a list of connections using JavaFX. Can you help me to optimize the code to make it much simpler?
package sqlbrowser.navigation;
import java.util.ArrayList;
import java.util.List;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javaf... |
I'm working on JavaScript bookmarklet that lets users send a text and link to a site.
This is the bookmarklet:
javascript:(function(){new_script=document.createElement('SCRIPT');new_script.src='http://bookmarklet.example.com/js/bookmarklet.js?v=1';document.getElementsByTagName('head')[0].appendChild(new_script);new_scr... |
I still have to implement API keys for client auth, but so far this is what I have for users. This was built using WebAPI and SimpleMembership with Forms Auth:
Is Authenticated:
public class AccountController : ApiController
{
public static DtoService _service = new DtoService();
// GET/api/isAuthenticated
[System.We... |
I just wrote the following javascript (jQeury loaded):
var valid, ui;
try {
$.each(this._cache, function() {
$.each(this, function() {
$.each(this, function() {
if (this.label.toLowerCase() === valueLowerCase) {
valid = true;
ui = {item: $... |
I built a code piece that makes it easy to execute a set of sequential operations, that might depend on the same parameter value (passed across the execution) or might need a particular parameter.
There's also a possibility to manage an error from within the operations, by implementing IReversible interface.
This code... |
Below is the code I have written. I started yesterday with prime numbers and playing around with them. What the code does it determines the "prime gap" between primes numbers, prints them, then finds the gap between these numbers, prints, etc. It starts to create a very cool pattern you can find some maths about it her... |
I have a table with 'nested' inputs that need to be checked or unchecked when a button 'select all' is pressed. There are several levels that can be toggled with their respective 'select all' button. In my code I have a repetitive .each() statement where the second one tests if there are differing numbers of checked/... |
My goal is to have a reusable pattern for doing concurrent stream-processing in Go.
The stream has to be closable from any node.
Errors should cleanly close the stream and forward the error to the consumer.
Should have a nice API
Here's what I came up with: http://play.golang.org/p/DSIPmKiAst
package main
import (... |
A few months ago, I wrote a query selector that seems to outperform the query selectors in the popular GP libraries by a pretty hefty margin. I'm wondering if I overlooked something. It seems odd that with all the manpower behind these other projects. It's this easy to come up with something that outperforms them.
The ... |
I have either created something beautiful or something monstrous, and I'm not really sure which, and I don't know where else to turn but here. What I've done:
var MyObject = function(opts) {
//init code, set vals, runs when 'new MyObject()' is called
}
MyObject.prototype = (function() {
//private helper funct... |
This works as intended, but was wondering if there is a more efficient way of coding this.
if (window.location.href.indexOf('/search/') >= 0) {
switch ($.cookie("Layout")) {
case "Poster":
$("link:first").attr("href", "../css/list.css");
break;
case "Description":
... |
I am trying to create a treenode structure based on a database table for a Dungeons and Dragons character creation program I am working on. I have come up with an incredibly confusing way to do it, but I am wondering if anyone can give me some better ideas on how to do this more efficiently. I have a tables called su... |
I need somebody to review and polish my GUI code for my very very simple chat client. I haven't built any of the server sockets, so I'll do that later, but for now I just want people to tell me how crap my code is and how I can make it better. I'll post the full code below, but keep in mind that it is built to be as si... |
Let's say I have a key 'messages' that is usually a list, but might be None, or might not be present. So these are all valid inputs:
{
'date': 'tuesday',
'messages': None,
}
{
'date': 'tuesday',
'messages': ['a', 'b'],
}
{
'date': 'tuesday',
}
If I want to retrieve 'messages' from the input, and itera... |
I have the library that I have found to be very useful when creating dynamic content rich web applications. I call it DO.js. It allows me to create entire DOM structures inside of Javascript in a similar manner that HTML markup should look. Additionally, it does it all without writing any HTML strings. It uses a hierar... |
I have a multi dimensional array like this:
[0] =>
['batch_id'] => '1'
['some_stuff'] => 'values'
[0] =>
['unit_id'] => '12'
['some_stuff'] => 'values'
[1] =>
['unit_id'] => '41'
['some_stuff'] => 'values'
This comes from an external API, so I have no control over the o... |
I'm taking a scripting language course with no prior scripting language or Linux experience, though I've taken classes in VB, Java, and C++. Our first assignment is to write a script that will traverse the directory tree of the location the script is run from and rename the files according to some predetermined rules. ... |
We had a requirement to remove the port number from the Request.Url.AbsoluteUr i.e
Actual:
https://mysitename:443/Home/Index
Expected:
https://mysitename/Home/Index
The code I used for this is
string newUrl = context.Request.Url.AbsoluteUri.Replace(":" + context.Request.Url.Port, string.Empty);
This is working fi... |
I am currently trying to implement a very simple MVC framework as a way of helping me understand how they work. My base controller class has 2 properties, a model and a view. All controllers have a generic view class property however only certain controllers have a model.
I needed a way of obtaining the name of the ch... |
Is there a better way to write the JS for this? I'm asking because I read from somewhere that using .hover isn't recommended. Also, if I move the mouse in and out of the box really fast, the box fades in and out the exact number of times I entered/left the box. How do I prevent this?
jsFiddle
$(".project-mask").hover... |
I am achieving a hover state per continent through:
var continentId =""
function getID(continentId){
jQuery.each(mapObject.mapData.paths, function(i, val) {
if (val.continent == continentId){
continentCodes[i] = "#3e9d01";
mapObject.series.regions[0].setValues(continentCo... |
I'm now developing an instant messaging system but I'm a little confused: I can't decide which approach I have to choose!
I want you to tell me what is good/bad with this programming approach. One friend of mine said it's difficult to read, but it works.
/*! | (c) 2012, 2013 by Bellashh*/
/// <reference path="jquery-... |
I create this class method to Enter Selected Items Form CheckboxList to associated resource I use ADO.net & store Proc to insert data can someone help me to improve it and make to so clean instead of my Hacks BTW I use Microsoft Enterprise Lib
public static void Insert(List<int> listSkills, int rID)
{
... |
I have a simple Java model Class called Person which have a constructor that receives a JSONObject. In that constructor I get the values from the JSONObject and put in my instance variables. This is just a simple question but which way is best?
public Person(JSONObject personJsonObject) {
// Without setter
this... |
This is a function I just wrote that tries to condense a set of strings into grouped lines. It actually works, but looks ugly. Is there a better way to achieve the same thing?
Take 4 filtering empty strings first and dropping the if line on the final yield
def mergeToLines(strings, length=40, sep=" "):
strs = (s... |
This method allows for the execution of parameterized commands within a DAL class, and I tried to make it as reusable as possible. It works well but it feels a bit verbose to me. Is there a way to simplify this or is it good as is?
/// <summary>
/// Retrieves records from the specified data source.
/// </summary>
/// <... |
original code example
if (var1 == null) {
String msg = "var 1 is null";
logger.log(msg);
throw new CustomException(msg);
}
if (var2 == null) {
String msg = "var 2 is null";
logger.log(msg);
throw new CustomException(msg);
}
if (var3 == null) {
String msg = "var 3 is null";
logger.log(msg... |
I have often read about how important clear and efficient code is. Also often people talk and write about 'beautiful' code. Some hints and critic from experienced developers for the following code would be extremely helpful to me. Another question that I often ask myself is about list comprehensions: I feel that in the... |
I have a class which is responsible for waiting until a message is added to a message list and then sending it off to get processed.
withdrawMessages waits for a message. I wait for a total of 2 minutes for a message to appear. I do this to keep the connection alive on my browser.
depositMessage adds a message to the ... |
I usually find the .js files to be quite messy and the truth is that mine are even worse than the average as, being soft, I'm not the sharpest tool neither at jQuery nor JavaScript.
I would really appreciate if someone could give me a heads up about improving the readability (and point me bad practices) of this code. I... |
I'm trying to update my website's code to HTML5's semantic and structural elements, but I'm not very sure with the sections and article element.
Here's the structure of my page:
<body>
<header id="heaven" style="background-image: url(" ./images/header/2.png ");"></header>
<nav id="outer-nav" style="position: ab... |
I have a list in Prolog like this:
Puzzle = [ A1, A2, A3,
B1, B2, B3,
C1, C2, C3 ].
And I want every variable in the list to be a number in the range of 1 to 9.
Currently I'm doing this like so:
between(1,9, A1),
between(1,9, A2),
% ...
between(1,9, C3).
Even though this works, it's already pr... |
I would like to hear your feedback on the link below that lets users add a link to a website. I read that javascript:void(0) is suggested instead of a # for the <a href="" attribute. Is this still the best practice?
<a href="javascript:void(0)" onclick="window.open('https://www.example.com/add?url='+encodeURIComponent(... |
I am trying to code Battleship. It should be a text one-player game against computer where computer and human player take turns in shooting at opponent's ships. I decided to start implementation with this part: A human types target coordinates and computer answers if a ship has been hit or even if it has been sunk. Shi... |
Please help make this code more cleaner. It's a part of window procedure that notifies my renderer before client area of window resized.
I need to check two combinations of bit blags: some of them must be set, and some must be not. How to do it without bunch of temp variables? (and probably calculate only 2 possible st... |
I want to retrieve id and name per skill. It works but is it well done? I would like to stay with minidom but all advices will be appreciated.
# This is only part of XML that interesting me:
# <skill>
# <id>14</id>
# <skill>
# <name>C++</name>
# </skill>
# </skill>
# <skill>
# <id>15</id>
# <skill>
# ... |
This is a basic sorting function written in jQuery that moves items in the DOM around to create empty spaces for a droppable(). Since there is so much going on in a droppable over event, i'd love some feedback on how this could be done better.
This is all in a function called on the over event of the droppable()
I hav... |
This is the first time I've written a class in Java to do encryption using AES. Since security is involved I would love it if someone could take a look at it and let me know if anything is wrong with my implementation. Additionally, any feedback about shortcuts I could have taken or sloppy processes I've used would be ... |
The code checks many more conditions like the one below. I was thinking to memoize it, but I can't think about how (writers block). How else could I optimize this? I know it seems silly, but my code is spending the majority of the time in the function.
def has_three(p, board):
"""Checks if player p has three in a r... |
I recently made this campus timeline for my university. When viewing the timeline on a mobile device (not a tablet), the navbar changes so that you can jump to the previous or next decade by clicking one of the arrows.
I'm concerned about the performance of the animation. I'm using a Samsung Galaxy S3 (one of the most ... |
I'm putting together a little application and it requires about 6 if statements to verify actions, here's the code I'm using:
if($player[0]['value'] == $server->clean_attr($row['attr1'])) {
if($player[1]['value'] == $server->clean_attr($row['attr2'])) {
if($player[2]['value'] == $server->clean_attr($row['at... |
I have the following C++ program:
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <vector>
void printVector (std::vector<int>& vec)
{
for (int a = 0; a < vec.size(); a++)
std::cout << (char)vec[a] << ", ";
}
int main ()
{
const std::string HANGMAN[] = {"\n------+",
... |
In MS excel, a date is also represented as a numeric value, with 1-Jan-1900 as the first day. Also in VBA there are dateAdd and dateDiff functions. dateAdd adds a given unit (day, month quarter or a year) to a date. dateDiff returs the difference between the numeric values of two dates. I have written a scheme code in ... |
I've been working in PHP since almost three years ago. In this time I built a framework as base for my projects.
I want it to be improved, and which other best option there are that use StackExchange?, so I decided to post this here.
The framework is hosted in GitHub:
https://github.com/CPedrini/Delos
Now, the problem:... |
This application is a "Student Registration System" using JDBC with Oracle as part of our school project. It works as it stands right now.
Questions:
What is a better way to structure the project? Why?
Any 'crimes' committed in the code?
Details:
I've decided to make the interface as a web service/page instead of a ... |
I wanted to wrap the jkeymaster library in a Clojure wrapper (for my own use, but perhaps also to save others some time). I'm just learning Clojure so I'm still not quite sure what "idiomatic libraries/APIs" look like. In Ruby, I would have created an object with methods, but in one of the clojure books they recommende... |
I am working on a program in which 10000 random non-repeating numbers are selectively sorted into ascending order"
import java.util.Random;
public class Sorting {
public static void main (String[] args){
//Here, we initiate an array with the integers
//1 through 10,000 in order.
Random rge... |
I have not completed this but want to make my own template library for wrapping the Win32 API to make it compatible with std::string/std::wstring... Here's a sample of what I've worked with so far.
My questions are:
Is this a good idea?
Is it acceptable to undefine Windows API macros (e.g. #undef GetWindowText)?
Is ... |
I'm a bit confused if saving the information to session code below, belongs in the controller action as shown below or should it be part of my Model?
I would add that I have other controller methods that will read this session value later.
public ActionResult AddFriend(FriendsContext viewModel)
{
if (!ModelState.I... |
How would you write this jQuery code cleaner and better? I'm a beginner.
$.extend({
misTip : function($tipSettings) {
$tip = $tipSettings.tip ? $tipSettings.tip : '';
$closeTime = $tipSettings.closeTime ? $tipSettings.closeTime : 1500;
$refresh = $tipSettings.refresh;
delete $tipSettings.msg;
delet... |
The function func(int m,int n) outputs (for m = 3, n = 5):
3
34
345
34
3
I came up with this code:
void func(int m,int n)
{
for(int i=1;i<n-m+2;i++)
{ int k=i;
int j=m;
while(k>0)
{
System.out.print(j);
k--;j++;
}
System.out.println("");
}
for(int i=n-m;i>0;i--)
{ int k=i;
int j=m;
... |
I've been teaching myself Ruby this weekend. First of all, I am aware that there is a built-in sort function. I've written this code strictly as an exercise.
I have background primarily in C# and Javascript, so this is a change of pace for me.
If you are a seasoned professional with a lot of Ruby experience, my code ... |
This is a simple packet sniffer that turns on LEDs when there's network activity. It works by picking up filters in a configuration file and listen for activity in those filters. When there's a captured packet, it sets a bit in a bit-mask that corresponds to the filter index in the config file. Then, once all the filte... |
I'd like anyone here to help me clean up my code. It's about calculating men's risk of getting coronary heart disease. Here's the link to my method.
private void calculateForMen(){
// TODO
// For Men
// 20–34 years: Minus 9 points.
// 35–39 years: Minus 4 points.
// 40–44 years: 0 points.
// 45–49 years: 3 po... |
I am working with an application that will have sub forms. The primary form opens above the system tray, and on mouse-over, secondary windows will open right next to the primary. When I use the Me.location = New Point () and then assign the point, it works great… until I change PC's and the user has a different screen ... |
Is there a way of writing this correctly working query more efficiently? I'm asking only to learn LINQ better:
var cpuInfo = edgeLPs
.GroupBy(k => k.CPU.ID, e => e.CPU)
.ToDictionary(k => k.Key, v => new
{
LogicalProcs = v.First().LogicalProcessorsCount,
Cores = v.Fir... |
As the question states: have I missed some obvious security vulnerabilities in this code? Particularly interested in XSS...
I'm trying to create something more robust that strip_tags, but simpler than HTML Purifier which just feels like overkill.
class StripTags {
private $tags;
private $dom;
function __con... |
Say I have a code snippet like this
if(string.Compare(isStandardFlag,"STANDARD",true)==0)
{
hearingID = centreSession.standardID;
centreSession.standardOutcomeID
= disciplineSvc.SaveResultA(hearingID,OffenceID, Outcome);
centreSession.standardOutcomeNoteID
= dis... |
I have two pieces of they which do almost the same thing. They both return the most common base class of two types. They differ in two aspect:
If one of the arguments is null, code A returns null and code B returns object.
If one of the arguments is an interface type, code A returns null and code B returns object.
My... |
i need to create a cache class to avoid making the same calculations more than needed. My idea was something really basic like
class transient_cache {
static private $cache = array();
static public function get_value( array $obj, $key ) {
// $obj is an array( $object, $method )
$classname = get_... |
I am new to Ruby and would like some help with re-factoring my code.
class Beam
def initialize
puts "Please specify span of beam"
@span = gets.chomp.to_f
puts "How many number of point loads do you want?"
@pointLoadNos = gets.chomp.to_i
@pointLoad = Array.new(@pointLoadNos)
@pointLoadDistFromLe... |
So for practice with Javascript, I wrote this lightweight widget factory which is similar in functionality (okay, that's a bit of a stretch) to jQuery's UI Widget factory. I was hoping I could get some pointers as far as idiom usage and also if there are any glaring problems with the below code.
var _CreateWidget = fu... |
I chanced upon this code written by the Solution Architect for an MS CRM project and I am lost for words. Am I going crazy or is this code OK?
string returnedOptionSetStringValue=string.Empty;
int returnedInt = 0;
Utils.RetrieveOptionSetLabelOrValue(CRMAccess.xrmService, Contact.EntityLogicalName, "new_status", option... |
I want to efficiently (few intermediate objects) and neatly (few lines and easy to read) filter an array, removing and returning rejected items. So like a call to delete_if except instead of returning the remaining items, returning the deleted items.
Here's some code that works:
ary = (0..9).to_a
odds = ary.select {|i|... |
Since I didn't find a way to properly transform JavaScript object to JSON with PHP, I wrote a snippet.
Lets assume the following excerpt from Google Fonts JavaScript API:
WebFontConfig = {
google: { families: [ 'Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic,700italic:latin,latin-ext' ] }
};
This, ... |
I have written my first jQuery plugin using one of the design patterns suggested on jQuery's site: http://docs.jquery.com/Plugins/Authoring.
As listed below in the description comment, it's purpose is to provide keyboard and mouse navigation and highlighting for the children of elements like tables, ul's, ol's, and na... |
I'm coming close to finishing a site where there are a number of jQuery functions going on. They all work, but the page is just running a bit too clunky. The fading in and out is just not as smooth as it should be, especially on the contact link, and the auto page scrolling is a little jumpy.
I've cached as many select... |
I've posted here before and got pretty helpful reviews. How does my code look now? To keep it really helpful, I just copied this from the middle of one of my projects.
<?php
function findSimilarityBetweenImages($imagePathA, $imagePathB, $accuracy){
//if images are png
$imageA = imagecreatefrompng($imagePat... |
It took me a lot of poking around and unit testing to get the code to look like it is right now. So I have a XML file which in part looks like this
<FunctionKeys>
<Name>F13</Name>
<Name>F14</Name>
<Name>F15</Name>
<Name>F16</Name>
</FunctionKeys>
and So I want to take that data and put it back into my ... |
Can someone help me with the following micro optimization for the F# code for lexicographic permutation?
I have code in C# which runs for 0.8s. As a learning practice, I translated it into F#. However, it becomes 2.9s. Just out of curiosity, I am wondering why my code in F# runs that slow? Are there any improvement can... |
Recently I have been developing a SASSified version of Dave Gamache's Skeleton CSS front-end framework. I have publicly posted the code on github as well as a live demo.
What I am looking for is constructive feedback on my project as a whole and ways to improve/simplify features. I believe my solution is far more eleg... |
Here is my shopping cart class! I want it to be perfect and never to have to implement it.
What improvements would you do?
New : IComparable
interface IComparable
{
public function equals($object);
}
New : ICartItem
interface ICartItem extends IComparable
{
public function setQuantity($quantity);
public fu... |
There is a lib code, trying to parse an Element Tree object. If exception happens, it either returns an empty dict of dict or a partially constructed object of such type. In this case, caller needs to parse the results to see if parsing is correctly handled or not. Or in other words, the returned dict is not determinis... |
private static List<ConstrDirectedEdge> kruskalConstruct(ConstructionDigraph CG) {
int current = CG.srcVertexIndex();
boolean visited[] = new boolean[CG.V()];
visited[current] = true;
UF uf = new UF(CG.V());
List<ConstrDirectedEdge> feasibleNeighbours = new ArrayList<ConstrDirectedEdge>();
List... |
I am working on my own PHP MVCframework. Now I want to know where to get and specify my entities.
For example, should I do this:
class User_Model extends Model {
private $name;
public getName() {}
public setName($var) {}
public getAllUsers() {}
public getUser() {}
public saveUser(User_Model $user) {}
}
or this:
... |
Calling code and attempt at building session variables:
DataTable dtServerVars = clCommonFunctions.TryAutoLogin("europe\\MrTest");
Session["CablingUserID"]= dtServerVars.Rows[0]["CablingUserID"].ToString();
Session["CablingUseremail"] = dtServerVars.Rows[0]["CablingUseremail"].ToString();
Session["CablingLogin"] = dtSe... |
Inspired by a recent question that caught my interest (now deleted), I wrote a function in Python 3 to rearrange the letters of a given string to create a (any!) palindrome:
Count the occurrences of each letter in the input
Iterate over the resulting (letter, occurrences) tuples only once:
If the occurences are eve... |
I need to improve this section of code:
uint32_t to_handle = 0;
uint32_t test_const1 = Constraint3::VAL1 + Constraint3::VAL2;
uint32_t test_const2 = Constraint1::VAL2 + Constraint1::VAL4 + Constraint1::VAL8;
uint32_t test_const3 = Constraint2::VAL1 + Constraint2::VAL2 + Constraint2::VAL4;
to_han... |
I find the tail in the first while loop and store it in the tailEnd node.
I update the tail to the previous node and change the tail.next to point to the previous node.
Once head.next.next == head, the reversing is finished.
package LinkedLists;
class Reverse {
public static LinkedList reverse(LinkedList No... |
I'm looking for OOP tips or advice.
;(function ( $, window, document, undefined ) {
if ( typeof Object.create !== 'function' ) {
Object.create = function (o) {
function F() {}
F.prototype = o;
return new F();
};
}
if (!Function.prototype.bind) { // check if native implementat... |
I am working on an application which first loads a 'settings' panel and then loads the application. It all works fine, loading the settings panel takes a few seconds longer than I would like it to. The problem is in loading the settings panel, not the application itself.
I have a simple main method:
public class Main {... |
I created a reusable function for changing block name in Djago templates. I want to know if the code is good or is there any probable issues in it. I developed the function as a hack for the following issue.
Template Code
{% extends base_name %}
{% block main-contents %}
<h2>{{ message_heading }}</h2>
<div c... |
I have some code for a calculator, and I was wondering what I could look at to make the code smaller, easier to read or better in any way. I'm particularly looking at my global variable x. Is there any way to change the code to completely remove that? Someone mentioned a getTwoInputs() function, but with multiple diffe... |
I'm extracting 4 columns from an imported CSV file (~500MB) to be used for fitting a scikit-learn regression model.
It seems that this function used to do the extraction is extremely slow. I just learnt python today, any suggestions on how the function can be sped up?
Can multithreading/core be used? My system has 4 co... |
for the following function
#!/usr/bin/ruby -w
e=0
g=0
h=1
while h < 10000000
a = h
f=0
while f !=1 && f!= 89
d=0
f=0
while a.to_s[d] != nil
e = a.to_s[d]
b = e.to_i
f += b**2
d+=1
end
a = f
f = 89 if [4,16,37,58... |
I just started to make a static website after years of not playing in that field (I stopped in the early 2000s) just to try to remember what I lost over time. Before going any further, I wanted to know if the way I'm building my page is working alright. It can be seen at http://kaivoslab.site44.com/.
I tried to keep it... |
I have this CoffeeScript code running here (with TZM-Blade) and would like to have your opinion on how to better optimize it.
express = require "express"
gzippo = require "gzippo"
assets = require "connect-assets"
jsPaths = require "connect-assets-jspaths"
stylus = require "stylus"
blade = require "blade"
i18n = requir... |
Referring to this post, my problem (summarized):
One main thread waits for connections, on accept() spawns a new thread for each connection. After we received n connections, the main thread dictates all threads what command to run, and must wait for all threads to finish, until issuing a new command later on.
I would l... |
I have to write a program in C that reads an array with n elements and then displays how many elements are bigger than the average of the elements of the vector.
Is there any other way to do this in a shorter or simpler way?
#include <stdio.h>
#include <stdlib.h>
#define SIZE 100
void readArray(int [] , int );
double... |
I have an object that's generated from an incoming json string. The string is deserialized in a custom converter that returns an object. This object has a method called IsValidForDB that checks if the properties are valid. This method looks like this:
public class MyObject
{
public bool IsValidForDB()
{
if ... |
I have a long-running task that processes an input file and then uploads it to a web server. The processing part can be interrupted (with cleanup) but the upload shouldn't be interruptable so that we know whether the server received the file correctly.
My thread looks like this (I'm using PyQt but I imagine this proble... |
I have some jquery that pretty much just runs a small drop-line navigation. Each tab size differs, so i used the same jquery line 5 times to make it look and function the way i wanted it to. I'm sure there is a way to condense it but im not quite a pro. Can anybody help me out a bit? The jquery is below, and here is th... |
I'm trying to compete on HackerRank and my answer got accepted, but the times are not so good. I have a friend who sent the answer in C# too but somehow made it a lot faster. I'm wondering what can I do to improve it.
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
class Solution {
... |
I'd like to design a settings class thread save. The settings have 2 attributes: String x and int y and should provide listener functionality to notify listener about changes. The problem is, how to make it thread safe.
Here is a complete code:
package org.example;
import java.util.Set;
import java.util.concurrent.Cop... |
I'm trying to improve my javascript and have been using the revealing module pattern to good effect but I noticed that code in the module not in a function or the return is executed on creation have utilised this, such as:
var MyModule = function ($) {
setUp();
function setUp() {
// execute code to be... |
I wish to ensure I am using the "best" pattern when using an Execute As/Revert from within a Try/Catch block on SQL Server 2012. The below code "seems" to behave correctly... Am I missing anything or are there any security concerns, "better" approaches, etc.?
Below is my code:
CREATE PROCEDURE [dbo].[TryItOut]
WITH EX... |
I had my original threading code which worked well, but since my tasks were shortlived, I decided to use thread pools through ExecutorService.
This was my original code
public class MyRun implements Runnable
{
private Socket socket = null;
public MyRun(Socket s)
{
socket = s;
thread = new Th... |
I want to get just the first and last values in a date range. I have the following code:
using (var myEntities = new dataEntities())
{
var myValues = (from values in myEntities.PointValues
where values.PointID == dataValue && values.DataTime >= fromDate && values.DataTime <= toDate
... |
I have this interpretation of John Conway's Game of Life in Python 3.3.1:
#JOHN CONWAY'S GAME OF LIFE
def countSurrounding(universe, a, b):
count = 0
surrounding = [[a - 1, b - 1],
[a - 1, b ],
[a - 1, b + 1],
[a , b - 1],
[a ,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.