It's a simple words counter app ..
$(document).ready(function() {
var wordsCounter = (function() {
function init() {
bindEvents();
}
// cache dom
var $textArea = $('#textArea');
var $words = $('#words'); //a span
var $chars = $('#chars'); //a span
func...
Error: { "message": "Uncaught ReferenceError: $ is not defined", "filename": "http://stacksnippets.net/js", "lineno": 13, "colno": 9 }
is it the stack snippet that's missing a library or there's something wrong with the code?
hmm there's no html/css in the snippet
I like the stack snippet idea very much, it's nice to be able to run the code right there in the post. You could add a bit of html+css - just enough to demonstrate the code in action; when I click to run your snippet, the output is Error: Uncaught ReferenceError: $ is not defined. If the code isn't meant to be executed on-site, it's probably better to edit the post and just keep it a normal code block, without the <!-- begin snippet and end snippet --> meta-comments. — Mat's Mug ♦55 secs ago
I was amazed by std::variant and got inspired to write my own. For now, it supports constructor+destructor pair, assignment operator and get<>() function to retrieve the value. The object doesn't allocate any dynamic memory. All of the supported functions are type safe.
Here is the variant:
#if...
Could you suggest any improvements in this lucas sequence's implementation :
from mpmath.libmp import bitcount as _bitlength
def _int_tuple(*i):
return tuple(int(_) for _ in i)
def _lucas_sequence(n, P, Q, k):
"""Return the modular Lucas sequence (U_k, V_k, Q_k).
Given a Lucas sequ...
I am new to Java and OpenGL.
I have a listener and I am trying to figure out why it isn't working? When I press a key absolutely nothing happens. Here are my files.
HelloOpenGL.java
package helloOpenGL;
/*************************************************************************************
* ...
As an integral part (pun intended) of my APL interpreter (previous questions: 1 2 3 4), this suite of functions converts any data into integer handles. APL operates on arrays of data cells, so with this encoding my cells are all int but may semantically contain other types.
common.h contains def...
StackOverflow is a Q&A site, not a place where someone writes code for you. I would recommend to try to convert the code yourself and post it to Code Review if it does not work. — Ruslan Batdalovjust now
I recently had quite a lot of run answering a Stack Overflow question, and I think I've gone a bit overboard and ended up with a fairly decent way of populating a ComboBox from a Range.
Given a simple UserForm featuring some ComboBox1 control that I'd want to populate from a ListObject on Sheet1...
I am currently writing a Java interface to a C library. It mostly just delegates calls and adds a object oriented layer on top of it to make integration into a regular Java program more natural.
The C library talks to a server (local) which in turn communicates with a real device.
My current de...
thanks for your comments. I'm more interested in a crypto review than a code review. May I rephrase my question as: would this be safe to share publicly iv, aad,encrypted string, and salt assuming that aes256 implementation is correclty done ? — landbit26 secs ago
my first post on codereview, I hope I'm within the bounds of a proper question :)
I'm using CodeClimaten to determine cyclomatic complexity. My method has complexity too high (6):
def play_card(self, card: KittenCard, player: Player = None, target: Player = None):
if card.selfcast and playe...
Assignment:
Write a program which reads a number n from the console. Then calculates the sum of all odd numbers between 1 and 2n + 1 (incl.).
Assignment also on GitHub, Exercise 0.0: https://github.com/xorpd/asm_prog_ex/blob/master/4_basic_assembly/0_branching/2_basic_conditional_branching/ex/2...
I wrote a simple console game, with the idea taken form a reddit post.
There are a few specific points I'd like to be adressed:
Are libraries included properly? I go by the logic "include library in a file if it is used in that file", is this correct?
Is my implementation of players acceptab...
I wrote a simple agent system based on the agent type from Akka. It allows you to encapsulate a mutable state in a thread safe manner for use cases where mutation would be most convenient (like for counters).
Agents must be created by invoking the module create method which requires the agent t...
I was amazed by std::variant and got inspired to write my own. For now, it supports constructor+destructor pair, assignment operator and get<>() function to retrieve the value. The object doesn't allocate any dynamic memory. All of the supported functions are type safe.
I wanted to use static_as...
This page is simultaneously a description and a demo. When you visit it, it shows a description of what tabnapping is. When you then click to another tab, it changes the tabs favicon and title to look like Gmail. Later, when the user wants to read her mail she goes to this tab thinking it is Gmai...
I don't really use Chromes, Firefox is my browser of choice
@skiwi The way to keep tabs from building up, I always shut down my computer, because I switch between several of them. I always close down all windows before I shut down to make sure I save anything important. This includes shutting all tabs before quitting a browser.
@microbuster There are a good numbers of options for chat bots others have made. All depends what you're looking to do with it. The chat bots we use on CR are programmed to help with site moderation/maintenance, if you're looking for something other than that you'd be better off looking at that link or asking around on some other SE sites
@MachineLearning this is a simple code example to solve a relatively simple concept. It is the OP's responsibility to take it as such and apply it in their code base in a way that does not increase technical debt. Those conversations are far more applicable to codereview.stackexchange.com. — David L9 secs ago
I would like to add though that in my opinion the current answer is definitely a valid answer. It might be incorrect but that's another story. If you don't like it, downvote it.
But I think it is definitely a valid code review to say "There is a formula for this, no iteration necessary"
Last night I was messing with image programming in C# and I tried to make a program that takes an image and transforms it into another image, built with emojis.
EmojifyEngine.cs
/// <summary>
/// Holds all methods involved in transforming a image into a emojified version of the image.
/// </sum...
This unload_event wrapper is no longer used in Chrome javascript shim layer for extensions (deleted in 2014). Try listening to the event via devtools (F12) - Sources panel - Event listener breakpoints - Load - [x] unload. — wOxxOm1 min ago
I'm new to Haskell, and am trying to learn the basics with a simple function that will calculate the list of primes up to a given value (using the Sieve of Eratosthenes). Here is my code so far, which has the problem of becoming very slow for large inputs nmax:
primes :: Integer -> [Integer]
pri...
I was trying the below problem from a competitive forum.The minimum test cases are passed. Do please let me know your comments.
Remove the repeated characters from the input string and output the resulted string.
Input string: "abcabd"
Output string: "abcd"
string input = "abcabd";
string outpu...
I need to turn a lot of html elements as editable elements. You will double click on the element to edit, press enter to validate (send a PUT to the RESTapi), press esc to undo.
I've written this piece of code:
var editable = (function() {
var DELAY = 300,
clicks = 0,
timer...
I have a function to export a list of students into a CSV file
when I click the button[Export To CSV], a dialog will appear with Progress bar with percentage completed,
when the function is done, the Progress bar displays 100% and show a message: Export Finished!, and close dialog.
I was usi...
I think that if the question's problem statement says one thing, and the code does another, then the code is not working and the question should be put on-hold until it is fixed.
I've made an IDE in Java, using swing. It uses a couple of resources (prefs.json and help.txt) and some imported jar files for reading the json. I know the code's quite long, but the answer doesn't have to be a very detailed one. Anyway, here's the code:
package io.j4cobgarby.github;
import jav...
> This book doesn't tell you how to write faster code, or how to write code with fewer memory leaks, or even how to debug code at all. What it does tell you is how to build your product in better ways, how to keep track of the code that you write, and how to track the bugs in your code. Plus some more things you'll wish you had known before starting a project.
I like this book already.
5
Practical Development Environments, O'Reilly. And yes, I wish I got this book 2 years ago instead of last Friday.
> Building from scratch (also known as a clean build) each time is often the only way to get the product to build reliably. This takes so long that the developer goes off and does something else. Consequently, every developer thinks that his build tool is too slow.
It makes you think about why you build your builds like you build them. How it can be done better. Where the bottlenecks are. What you should look for in a testing environment.
This question appears to be off-topic because it is a code review request. This is better suited to the Code Review Stack Exchange site. Before posting there be sure to read their FAQ to ensure that your question meets their guidelines. — John Conde18 secs ago
> As soon as a project has more than one person working on it, communication within the group becomes vital. By default, communication seems to occur in the slowest, most error-prone ways that it can. If there is some choice between two things, then both choices will usually be made within a project, sometimes at the same time!
Given the following data as input, write a standalone executable or standalone script that will
print to the console or write to a text file the following:
Each household and number of occupants followed by:
Each First Name, Last Name, Address and Age sorted by Last Name then First Name where the...
> Fortunately, the game keeps track of the time and after a few hours of gameplay will ask the player to take a break and a coffee - a saveguard which is much needed.
This code seems surprisingly fast at checking if a number is prime.
def is_prime(number: int) -> bool:
"""Checks if a number is prime or not"""
# number must be integer
if type(number) != int:
raise TypeError("Non-integers cannot be tested for primality.")
# negatives are...
@user2296177 for example I made a small project yesterday. I was waiting for the new episode of Steven Universe to be released on a site (a total legit website!) and needed to take a break from spamming f5 to eat, so I just sticked together like 10 lines of code to check for me (and trigger an ifttt maker channel thingy to send me an sms) in 5 minutes. twitter.com/ardaozkal/status/774160067952160768
I could probably make it faster and less cpu depending or whatever if I used C++, but I don't think that I could be able to do it in 5 minutes
> "Fixed Paul's ugly code." "I hate this parser!" "Stupid customer request implemented against my better judgment." Such commit messages seem funny at the time or may temporarily relieve some frustration, but remember that the purpose of SCM tools is to store information for a long time. None of these messages will tell someone looking at the code two years from now why you bothered to change it at all; it's just noise to be ignored.
> Take a breath and write a message that you might want to find yourself reading a few months from now. Huge messages rarely get fully read either. If the message is that large, then add it to the project documentation elsewhere and refer to that file in the commit message.
/**
* Returns a global variable.
*
* Needed because a @grant other than none puts the script
* in a separate scope.
*
* @param {string} name The name of the global variable.
*/
function getWindowVariable(name) {
return window.eval(name);
}
@ali It would need some serious clean-up to fit the guidelines first. As it currently stands, it's not clear what he's trying to achieve which would make it Unclear at CR. — Mast59 secs ago
That is a poor comment at the top of your function. Please replace it with a documentation string that explains the purpose of the function, as in this part of PEP8. Also, this seems to be a question for CodeReview, not this site. — Rory Daulton12 secs ago
@ceving, tried to research whether this question should be posted to codereview insted, but I am not yet convinced that it is off-topic for SO. This guide to code review for SO users specifically advises: "Please do not vote to close with a custom reason that 'it belongs on Code Review'" — Tomas Langkaas21 secs ago
Here is my favorite user defined function in python,
def replace_outfolders(outfolders):
''' Replaces given list of output folders '''
# imports
import shutil,os
for outfolder in outfolders:
if os.path.exists(outfolder):
print('Replacing folder: ', outf...
I have a self referential database table:
CREATE TABLE category (
id INT PRIMARY KEY,
name VARCHAR,
parent_id INT REFERENCES category (id)
);
And the following INSERTS:
INSERT INTO category (id, name, parent_id) VALUES (1, 'Programming', null);
INSERT INTO category (id, name, par...
Wikipedia is not very explicit on this,
The exploit employs scripts to rewrite a page of average interest with an impersonation of a well-known website, when left unattended for some time.
What is 'tabnapping', how does one do it?
This page is simultaneously a description and a demo. When you visit it, it shows a description of what tabnapping is. When you then click to another tab, it changes the tabs favicon and title to look like Gmail. Later, when the user wants to read her mail she goes to this tab thinking it is Gmai...
@Mat'sMug It's okay, I immediately thought of myself too
Original Code:
Getting name from user, and handling any errors in C
Fixed the bugs, anything else to consider?
#include "stdafx.h"
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdbool.h>
#define BUFFSIZE 10
/*Checks to see if name contains actual characters and not jus...
I have implemented my own Observer pattern. I want to post my events in a new thread. This thread would simply call all the the observers/listeners with the posted event.
public class EventManager
{
public void post(Object event)
{
new Thread(new MyRunnable(this, event)).start();...