instruction stringlengths 71 71.9k |
|---|
This is a comment system that I wrote, is it secure?
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="style.css">
<?PHP
//Turn off error reporting (Not Necessary)
error_reporting(E_ALL ^ E_NOTICE);
//Connect to the database
if (!@mysql_connect('localhost', 'us... |
I have this function in this fiddle
JavaScript:
var newsTicker = function (ele) {
var eles = ele.find('ul li'),
indexEle = 0,
dataEle = ele.find('.ticker-post'),
rotateChars = function (title) {
dataEle.text('');
indexCut = 0;
rotateCharsTimer = setInterva... |
This is my code to check if a string C is an interleaving of Strings A and B. Please suggests optimizations, and where I can improve.
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <iostream>
#includ... |
This is my adapter class, to create a custom listView with three radiobuttons:
public class Attendancelist_customadapter extends ArrayAdapter {
///needs two arraylists - one for the peopledetails, and one for the attendance status. read from file. passed to this.
///then assemble into a ListView with customview... |
I am using building REST services for file upload on the server. Here is some code of that
[OprationContract]
[WebInvoke(Method = "POST", UriTemplate = "UploadFile/{fileName}")]
public string UploadFile(string fileName, Stream fileStream)
{
string filePath = serverDirectory + "\\" + fileName;
using (var output = Fi... |
Description
This is a follow-up question to Tool for creating CodeReview questions.
Things that has changed include:
Removed replacing four spaces with one tab, all tabs and all spaces in the code itself is now left as-is.
Added file extensions to the output.
Switched order of lines and bytes as I feel that the number... |
KMP algorithm is for searching and matching string with a given pattern. The most important part is to build a table for the pattern then move a proper step rather than just one step increment.
In my code I created the table correctly but something is wrong for moving steps.
It stuck in the for loop as variable was al... |
One of my classes regularly triggers one of two asynchronous operations: a "turn on" and a "turn off" that each take about a second. I'm using this method below to make sure that they don't run simultaneously. It doesn't seem very elegant to me. Is there some better way to do this? I'm using .NET 4.0, but I would like ... |
This script scrapes recent articles on bitcoin, does sentiment analysis, and does some mock trading based on the sentiment of the articles. I'm looking for advice on code style, and I would love to learn how to write beautiful Ruby.
require 'coinbase'
require 'sanitize'
require 'cgi'
require 'htmlentities'
require 'se... |
For the past four years I've attended a private school which requires its students to wear ties. I've found that it's far easier to figure out what combination of shirt, pants, and tie that go together the night before, as it can sometimes be a tedious process. To make this process simpler, I had the idea to create a s... |
Using Rails 3.2, I have the following:
g = Geocoder.search(address)
# if no address found, geocode with latitude and longitude
if g.empty?
g = Geocoder.search(latitude, longitude)
if g.empty?
log.info "Geocode failed for #{latitude}, #{longitude}"
end
else
---save---
end
If the first geocoding with addres... |
This is in preparation for a competition that only allows C++03.
// Neighbor index plus weight of edge connecting this vertex with neighbor
struct NeighborWeight
{
Index neighbor;
Distance weight;
};
// Represents adjacency information for a single vertex (contains all
// neighbors and weights of edges connecti... |
Given a set of 2 dimensional points, it returns the two nearest points. If more pairs have the same min-distance between them, then an arbitrary choice is made. This program expects the points to be sorted on the x-axis. If not, input is unpredictable.
I'm looking for code review, optimizations and best practices.
fi... |
I decided to work on putting together an Arena-style (very basic) text-based RPG as a way to help myself learn Python. Unfortunately, after about 1,000 lines of pieced-together code, I realize that I've been doing myself a *dis*service by reenforcing poor practices, and by going line-by-line, my inefficiency is multip... |
Is there anything that I could have done better in this code?
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Quotes</title>
<style>
body { color: #333; font: 20px georgia; }
em { color: #555; font-size: 90%; }
</style>
</head>
<body>
<article id="quotes"></article>
<script>
(function() {
"use strict";
... |
I'm writing a parser for HTTP Authorization header (see RFC2616#14.8 and RFC2617#1.2). Note that I explicitly don't care about the base64-encoded syntax used by HTTP Basic authentication. I'm only interested in the auth-param syntax used by Digest authentication (to be more specific, I'm implementing a custom Authoriza... |
My boss needs me to embed the MD5 digest in a file path, but the problem is MD5 contains escape characters.
I've already taught about a uc%duc%d... format, but it also makes lengthy file names. In Linux it's not a problem since the Linux kernel could handle them.
char * uc_encode_md5(const char * password)
{
char dig... |
I am new to linq to objects in C#. I have the following query which works adequately. Is there someway to reduce or rewrite this query using joins or something else?
var query =
from container in containers
let items = container.GetItems()
from itemA in items
let tag = CreateTag... |
Requesting code review, best practices, optimizations for this solution to the Tower of Hanoi problem.
final class PlatePair {
private final String source;
private final String destination;
public PlatePair (String source, String destination) {
this.source = source;
this.destination = dest... |
I need to call an upsert to my Category table in PostgreSQL. My current solution uses the exec_query API in ActiveRecord, using binding.
What I got so far looks like this:
VERIFY_CATEGORY_SQL = <<SQL
WITH sel AS (SELECT id FROM categories WHERE name=$1 AND source=$2),
ins AS (INSERT INTO categories (name, source,... |
Rewrite readlines to store lines in an array supplied by main, rather than calling alloc() to maintain storage. How much faster is the program?
Here is my solution:
int readlines(char **lineptr, char *storage, int maxlines, int storage_size) {
int len;
int nlines;
nlines = 0;
while((len = _getline... |
I've written a custom binding for KnockoutJS which renders <select> elements with <optgroup> children.
When run, this binding adds <optgroup> and <option> DOM elements.
In order to make the binding two-way I obviously need to 'record' the observables for each of those newly-added DOM elements. I've done this using
ko.u... |
I wanted to fiddle around with the BackgroundWorker and Task classes, to see how I would implement a given task with these two techniques.
So I created a new WinForms project, and implemented a simple UI; two sections, each with a ProgressBar, and Start + Cancel buttons:
I implemented a DoSomething-type "service":
pub... |
Is it possible to write this in fewer lines of code?
If you input an integer it will output it as an ordinal number if it is less than 100. The below code works perfectly, but I'm wondering if it could be written more succinctly.
def ordinal(self, num):
"""
Returns ordinal number string from int, e.g. 1, 2, 3... |
While trying to teach myself C, I decided to take a stab at writing this Tic-Tac-Toe program on a 4x4 board. It will be great if somebody could review it and let me know of some ways of refining this.
#include <stdio.h>
#include <stddef.h>
typedef struct {
int xpos;
int ypos;
} BRDPOS;
void printBoard(int brd... |
I am building a Chrome extension that injects a small overlay in to all websites using a content script. At this point all the injected elements do is sit in the bottom left corner. It has two buttons the top one produces another element and the button one doesn't do anything. The extra element has a button that closes... |
With the help of some people here and there, I wrote the module below which works very well if the file targets.csv is not too big.
As soon as this file exceeds 100 MB, a MemoryError is returned.
The problem is that I used numpy to make the computations faster (and they became really fast compared to the previous versi... |
Even though I am working with one socket, I have wrapped it with an object which allows .recv() method which accepts timeout, using Python's select.poll().
The initialization of the wrapping object defines a socket using the address/protocol family, of type stream; then it connects, flags it as non-blocking and registe... |
I've got this largish (for me) script, and I want to see if anybody could tell me if there are any ways to improve it, both in terms of speed, amount of code and the quality of the code. I still consider myself a beginner, and I think that there are parts of my code that aren't maybe all that good - for example, all th... |
I am trying to create a simple validation for forms. I am almost there, but there are few bugs and optimization errors that I am really struggling with. I'm looking for advice on how to make this function simpler and more understandable.
var errorMessage = {
required: "This field can not be empty",
email: "Plea... |
I am working on Android applications for last 2 years and about 80% applications I have developed involve web-services consumption followed by some sort of XML or JSON parsing. Initially, when I had to call a web service, I had to create a separate AsyncTask class and then parsing was also the part of that AsyncTask cl... |
I need to create an efficient algorithm that returns unique values from an unsorted input. I don't know the length of the input.
As the function that will call this algorithm can abort the reading at any time, I think that using a well defined Iterable implementation is the right way, so I will not waste extra processi... |
I'm using simple script to handle tab menu like this:
HTML:
<nav id="personal">
<ul class="clearfix">
<li id="personal-info">Info</li>
<li id="personal-orders">Orders</li>
<li id="personal-models">Models</li>
<li id="personal-balance">Balance</li>
</ul>
</nav>
<div id="personal-... |
I am trying to populate a vector of integers with one billion random number. The only constraint is that there can be no duplicates in the array.
#include <iostream>
#include <algorithm>
#include <vector>
#include <ctime>
using namespace std;
int main()
{
srand(time(NULL));
vector<int> container;
vect... |
I am trying to find whether a given number is a perfect square or not by using just addition and subtraction.
Please review my code.
#include<stdio.h>
int check(int);
main()
{
int N;
printf("\n Enter the N:");
scanf("%d",&N);
if(check(N))
{
printf("\n[%d] Perfect Square:\n",N);
}
... |
I was asked to create a function that checks if an array of doubles has all negative numbers or none. If these 2 (all negative, all positive) are false, check the first negative number, using recursion and only using built-in C++ features.
int first_negative(const double val [] , unsigned array, unsigned short instanc... |
There is no error checking in day_of_year or month_day. remedy this defect.
Here is the solution:
int day_of_year(unsigned int year, unsigned int month, int day) {
int leap, i;
leap = ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0));
if(((month >= 1) && (month <= 12)) && ((day >= 1) && (day <= ... |
I don't understand what is taking the program so long:
#!/bin/python
primes=[]
i=0
j=0
k=0
for i in range(2,2000000): #fill in the list
primes.append(i)
i=0
while i<len(primes):
j=primes[i]
print(j)
k=0
while j*(j+k)<primes[len(primes)-1]: ##referred as 'line A'
try:
primes.re... |
I'm just starting to learn PHP. I have three random questions about PHP and one question about Code Review. None of them are technical questions ("will this work?"); they're best practices questions ("is this the best way to do this?"). Can you offer advice?
I put commonly used data in separate files and use include t... |
I'm working on a small GTK+ program and I'm now implementing undo and redo capabilities. This is the code that I'm using to handle the different states.
It's just a linked list storing the allocated char * returned by the text buffer. It monitors the size of the structure and the char *s so it will always be less than ... |
I am solving one problem with shortest path algorithm, but it is too slow.
The problem is that I have N points and these can be connected only if the distance between them is smaller or equal than the D. I have a start index and finish(ciel in code) index and have to return the shortest path in double format.
Firstly ... |
This is a (relatively) cleaned-up version of a Python script I've been working on for the past day or two based on Tim Golden's first solution to the above problem. I know about watchdog but I'm trying to keep dependencies down to a minimum.
I'm concerned about how Pythonic my code is, as this is the first "real" scrip... |
The purpose of this code is to return an address for one of the seven judicial circuits for the cases that is passed into the function.
I am taking a Node ID, which is a 3-digit number the circuit number is the first digit and the county number is the last two digits.
Set oNode = XmlDoc.SelectSingleNode("/Record/Cell... |
I'm writing a program to process log files. Currently, I have a script that will extract the desired information from each log and put it into a list - I have about nine different lists all containing different information.
Currently, I'm loading the file, extracting the desired information, and storing it in a list, ... |
I am very new to Java so please ignore if there are obvious mistakes. If my question seems redundant then please guide me towards the correct link. However, I have surfed enough in order to find the answer. Any changes in code will be greatly appreciated.
I am reading an input file and storing the elements of it in a 2... |
I have this code in a model for an invoicing app. This virtual attribute current_invoice gets the only non-rescinded invoice associated with a contract. The code works but it seems really verbose. Can this be done in a prettier way?
def current_invoice
result = []
invoices.each do |i|
if i.current_statu... |
I just want to know if my schema file is correct:
XML File:
<?xml version="1.0" encoding="UTF-8"?>
<xs:books xmlns="http://www.w3.com/1999/XML/prjXMLValidation"
xmlns:xs="http://www.w3.org/2001/XMLSchema/prjXMLValidation"
xs:noNamespaceSchemaLocation="collection.xsd">
<xs:book title="A Lesson Before Dyi... |
My work is pretty simple. I have to migrate a bulk of data into the specified tables, so that the data does show up at the front-end. The data is provided through the Excel sheet and I have to convert it into a CSV file with $ as a field delimiter.
And later I have to write a method in an Active Record Model to perfo... |
Help me refactor this class that helps to represent an object state as String:
public class ConvertorToString {
private static final String SEPARATOR_BETWEEN_FIELD_NAME_AND_VALUE = "=";
private static final String SEPARATOR_BETWEEN_FIELDS = ", ";
private static final String OPEN_FIELDS = "( ";
private s... |
I have implemented a linked list. I feel I overdid it with pointers, used old standards and C++11, and I ended with too many lines of code. I will make my quotations into two parts: one for the Node and iterator struct and the other for rest of the class.
For node and iterator, how can I optimize for C++11? Can you r... |
This is part 2. My problems are with too any pointers and with long body code in the following functions:
void push_back(T_ data);
void push_front(T_ data);
T_ pop_back();
T_ pop_front();
void insert(iterator_t& i, T_ data);
void erase(iterator_t& i);
T_ front();
T_ back();
void print();
void clear();
private:
... |
I have implemented the following PHP magic method behavior to save my time of creating accessor and mutators for properties of any class that extends this base class.
I am looking for suggesiongs on improving it for my application that assumes the following:
Properties of the form:
$_first_name
$_user_id
Methods of t... |
I'am trying to build a PHP/MySQL/jQuery comment system. Off late I started to realize that manual spamming is a serious issue that need to be addressed carefully. So I thought of building a PHP function (initially, later can be implemented in OOPS concept) that will sniff the content and give points (spam points) base... |
This will be a function that returns a random number from Dice Notation (more on Wikipedia). I will later use this function to determine whether some skill check is passed or not.
Is there any need for optimization?
If so, how?
Any other thoughts about this code?
#include <string>
using namespace std;
int toInt(s... |
I have a Python script I have written to copy files to a mounted Windows SMB share on a Mac.
import os
import distutils.core
# Create a local site for the mount to reside
directory = "/Users/username/share"
if not os.path.exists(directory): os.makedirs(directory)
# Mount the Windows smb share
os.system("mount_smbfs //s... |
I have inherited a function which calculates a first payment due after a certain age.
Using the function I typically pass in database values to custom calculate certain dates:
Dim result = FPDA("#1/12/1952#", "9/29/1948", 1, 55)
MsgBox(result) 'in this example, I am returning first payment due after age 55
As ... |
I am trying to speed up the process of inserting all of the rows in my text file into an Access DB. I originally switched to this route because of the size of those text files (that I am generating on another step of my process). I have more ROM than RAM. The overall process is working now, but I am falling into the ra... |
I've got a view which has a corresponding template. The template looks something like like:
<div id="streamItems" class="left-list droppable-list"></div>
<div class="context-buttons">
<div class="left-group">
<div id="shuffleButtonView" class="view-placeholder"></div>
<div id="repeatButtonView" cl... |
My intention is to separate components on a file basis. For example, I want a specific controller to have it's own file (Same goes with services, filters and directives). Of course, files will be group together based on the module they will fall into.
Here's an overview of what I currently have:
Directory
User/
Us... |
Not a follow-up, but related to Member list reveals member information on click (#1). I now want my CSS reviewed.
What I'm doing?
The content in a list of members is revealed by jQuery (see review #1). Instead of having the content pop out, I'm using a transition to make this smooth. Because one can't transition to hei... |
Partial ordering may be useful in some scientific contexts. This is quick prototype in Python, which I believe works correctly.
Do you notice any flaws? Can you provide a counter-example of wrong results? Additional test cases will be also rewarded with +1.
#!/usr/bin/env python3
import unittest as ut
def leq (L1, L2... |
I am interested in the performance tradeoffs of linked lists, standard lists and unrolled linked lists. This will depend on various factors including what operation is being performed (e.g. delete, insert, and from where), and the size of the nodes. I've written some performance tests (not listed here).
I am interest... |
My class takes functions as a parameter. There are 6 of them, along with numerous other parameters. Almost all of the fields have default values.
It also has a class method that creates an instance of the class with 2 of the fields initialized randomly. It has a subclass that cheats a bit by making 2 of the function... |
I have solved fibonacci series and then used the topdown and bottom up approaches to solve it. Also I have included the stairway climbing question as follows "You are climbing a stair case. Each time you can either make 1 step or 2 steps. The staircase has numStairs steps. Returns In how many distinct ways can you cli... |
I recently had a Java interview where I was asked to write a client-server application. I don't code primarily in Java, but with my preliminary Java knowledge, I thought I built a reasonable working solution. After evaluating my solution, I was told that I wasn't going to be interviewed further. I'm fine with their dec... |
It took me a while to figure out how to write this code, but I'm glad to say that I did eventually figure it out.
Can someone tell me what they think about it? Is it well written? What could have been done better?
Note that I am going through exercises in a book; I know there's a math.h that problem solves this, but I... |
Given a staircase with N steps, you can go up with 1 or 2 steps each
time. Output all possible ways you go from bottom to top.
I'm looking for code review, best practices, optimizations etc. Complexity: O(2n)
public final class StairRoutes {
private StairRoutes() {}
/**
* Given a sta... |
I have this WCF service providing search functionality - to be used by our client in his web application. There can be any number of search parameters and possible nesting of AND/OR operations.
Could you please have a look and share some ideas on if I can make it more client-friendly?
<con:Search>
<con:clientID>... |
I am programming a rotator using Delphi, with two different angles: azimuth and elevation. Up to now I am testing, so I tried to move the rotator 1 by 1 degree in azimuth and elevation. The rotator starts in (0,0) and finishes in (30,30).
Another important thing is that I need to pause or have the program sleep before ... |
I've written this minishell but I'm not sure I'm making a correct control of the errors. Could you give me some advice?
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#define LINE_LEN 50
#define MAX_PARTS 50
int main ()
{
char* token;
char str[LINE_LEN];
char* arr[MAX_PARTS];
int... |
The input pointer *data contains the data that needs to be split into different arrays and put in yuvInput. Each pixel is 32 bytes 4 * 8. Note the (j*4) to break it up per pixel segment. The 4th byte is the alpha channel which gets skipped (the reason there is no idx+3).
This method needs optimization. If anyone is... |
I'd like to get input on my approach of continuously receiving messages from an Azure Service Bus queue using the async part of the library.
My main concern being whether its "safe" to use Task.Factory.StartNew to process the incoming messages and then continue to call the Action's to continue receiving new messages.
T... |
A friend of mine has a popular open source JavaScript library which is quite well used in the community. He is now going through a process of refactoring and applying best practices and conventions and is wanting to upper case all constructor functions. So in the past where he may have defined a chart object, he now ... |
I have implemented code for parsing annotation:
/**
* @Route(path="sample \n test",code,value,boolean,test)
* @access(code=false)
* @sample as asdad asd
* asd
*/
function sample()
{
}
$refelection = new ReflectionFunction("sample");
$pattern = "/@(\w+?)(.*?)/U";
preg_match_all($pattern, $refelection->getDocCom... |
I've written this as part of my contact form on my website. It checks to see if required inputs are empty, if so adds a red warning color and text. It also checks the email field for a properly formatted email.
This code works 100%, but somehow I feel like I'm repeating myself and I am not sure how to eliminate the rep... |
I'd like this reviewed.
Demo
HTML
<body>
<!-- Introduction to the text shadow property -->
<div class="container one">
<h1>The Dark Knight</h1>
</div>
<!-- Show the inset shadow 'hack' -->
<div class="container two">
<h1>The Dark Knight Rises</h1>
</div>
</body>
CSS
body{
... |
I solved this problem in Ruby:
Write an utility that takes 3 command-line parameters P1, P2 and P3.
P3 is OPTIONAL (see below) P1 is always a file path/name. P2 can take
the values:
“lines”
“words”
“find”
Only P2 is “find”, then P3 is relevant/needed, otherwise it is not.
So, the utility does the following:
If ... |
To test incoming data for string values that are too large for the "database" (MS Access), I could do this:
private void SaveToMSAccess(InventoryItem invItem, string dbContext)
{
invItem = TruncateVerboseStringMembers(invItem);
. . .
}
private InventoryItem TruncateVerboseStringMembers(InventoryItem invItem)
{... |
Example: 00010111 -> 11101000
public long reverse(long x) {
long r = 0;
int i = 0;
while (x > 0) {
int bit = 0x0001 & x;
r += bit << (63 - i);
x >>= 1;
i++;
}
return r;
}
Can someone review my code and provide any comments or suggest a better way of doing this?
|
I am writing a script which checkout a git repo to certain commit hash, do something and switch back to master. The purpose of this script is to take homework solutions of students from bitbucket. Note that all the repos are under same bitbucket account. There is a master bitbucket account which is admin of all these r... |
I am trying to print the elements of an array into a table, but I'm having trouble formatting the array elements itself. Perhaps there is a better solution than what I'm currently using?
import java.util.Scanner;
public class RainFall{
public static void main(String args[]) {
//create rainfall array
double[... |
Suggestions for improving coding style are greatly appreciated.
import qualified Data.List as L
import qualified Data.Map.Strict as M
import qualified Data.Vector as V
type Queue a = ([a], [a])
emptyQueue = ([], [])
pushListToAnother fromLst toLst = L.foldl' (\ys x -> (x:ys)) toLst fromLst
enqueue :: Queue a -> a ... |
I would prefer if more experienced users could give pointers on how I can optimize and think better when writing code.
Using Homework Questions as reference, as this is a homework related question. This should fall into the second category. I know the code is working and that no memory is leaking. The implementation no... |
This is my first more-than-1-line script. It takes an input folder and a file prefix and gets all the matching files. For the first of the files, the script grabs the first line and appends an extra label string and puts that into $data. For all files (including the first), it takes the second line, adds the timestamp ... |
Could this script be shortened?
import random
def var():
strength = 10
skill = 10
dice4 = 0
dice12 = 0
dice_score = 0
character_name = ""
attr_list = [character_name, strength, skill]
character_name = str(input("Please enter your characters name: "))
skill_func(strength,skill,dice4... |
I was asked in my textbook Lectures on Discrete Mathematics for Computer Science to construct a program that would take an alphabet ({a,b,c} or any combination of characters {1,4,s,a}) as well as a length value and calculate all possible combinations of this alphabet.
For example:
char[] alphabet = new char[] {'a','b'}... |
I have a long set of IF statements that basically set a null object Value to 0, I feel that because i am doing the same action each time their has to be a simple way to make this allot shorter. It just looks like something I wouldn't normally see in code.
My code looks like this:
if ($data->sl1 === NULL){ $data->sl1 = ... |
I have a bit of trouble simplifying the binary search code. This is different from the traditional binary search because we effectively want to find the location for which A[j] is the least element larger than the current unsorted value.
Thoughts?
def binary_search(A, value, start, end):
# we need to distinugish wh... |
A little background first - I'm working on a server application that requires the ability to use multiple data access class libraries based on the resources available on the server it is installed on (MySQL, SQL Server, XML, etc.). The are currently implemented as modular plugins, where the executable is paired with t... |
I am writing small roguelike game where I spawn some items and put them into the std::list. Is this the right way to do it?
The Item class is as followed (I know it has public id property):
class Item {
public:
Item();
~Item();
unsigned int id;
};
Somewhere in the code I also defined:
list<Item*> listOfItem... |
A little disclaimer: you're going to have a field day with this. It's horrible. Looking at it makes me want to vomit, and don't ask me to explain it, because I've long forgotten what I was thinking when I wrote it. That being said, I can't really find a way to shorten it of make it make sense. Perhaps someone could hel... |
I've written the following code, but I need some review on design style. I want to develop a library/module and expose an API to client programs. How do I do that?
The code just runs a TCP server listening for incoming messages and another thread accepting user input to send messages.
from socket import AF_INET, SOCK... |
I'm using two category filters from this demo. I give the filters two different sets of classes so they won't affect each other. Since I'm very new to jQuery, all I can come up with is repeating the same code with a different set of classes. I wonder if there's a shorter way to write this:
$(function(){
/* filter1... |
I have a Java dynamic proxy with an invoke method that looks like this:
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
Object result;
try {
//Not sure if this line is ok?
Token token = (Token) args[0];
System.out.println("Token with id: "+... |
The following two functions are used to compress arbitrary Python objects and send them safely via socket or email, using only printable chars. In my specific message protocol, '=' signs are also not allowed; I could have replaced them or truncate them - I chose to truncate them.
I think they work quite well speed-wise... |
I am retrieving information from an SQLite database that gives me back around 20 million rows that I need to process. This information is then transformed into a dict of lists which I need to use. I am trying to use generators wherever possible.
What optimizations can be done?
I am either getting a “Killed” message or ... |
I am making a program to find primes between the given range of numbers. Unfortunately, the algorithm I created is too slow. Do you have any ideas of how to optimize the code?
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args)throws IOException {
Scanner s =... |
I'm starting to learn Clojure, and would like feedback on some code I wrote to manage database migrations. Any recommendations to make it more robust, efficient, idiomatic, elegant, etc... are welcome!
(ns myapp.models.migrations
(:require [clojure.java.jdbc :as sql]
[myapp.models.database :as db]))
... |
I am using RequireJS JavaScript library. I have the following JavaScript module define for dataservice:
define(['jquery'], function ($) {
var callApi = function (url, type, dataType, data, callback) {
$.ajax({
url: url,
type: type,
data: data,
dataType: dataT... |
I am having some issue to use PHP5 password_hash() function. My server is not supporting it, so I am using a function to hash. Is this one secure?
public function Pass_Hash ($password) {
$blowfish_salt = bin2hex(openssl_random_pseudo_bytes(22));
$hash = md5(crypt($password, "X1;G^COU8U`Bo*A6@9<on5yQ6P87M]... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.