Skip to content

Instantly share code, notes, and snippets.

@swuecho
swuecho / Trie.js
Created November 21, 2016 00:19 — forked from tpae/Trie.js
Trie.js - super simple JavaScript implementation
// Trie.js - super simple JS implementation
// https://en.wikipedia.org/wiki/Trie
// -----------------------------------------
// we start with the TrieNode
function TrieNode(key) {
// the "key" value will be the character in sequence
this.key = key;
@swuecho
swuecho / tar_test.c
Created November 19, 2016 05:16 — forked from danikin/tar_test.c
Tarantool Quick Test
// Tarantool quick test
// Copyright, Dennis Anikin 2016
//
// Quick disclaimer:
//
// This test shows 500K-1000K transactions per second on one CPU core
// and 600K-1600K queries per second on one CPU core.
//
// Based on the $6.57 per-month-price for the AWS t2.micro instance we can afford the tremendous number of 630bln queries for just $1
//
@swuecho
swuecho / Tree.scala
Created July 28, 2016 01:36 — forked from dholbrook/Tree.scala
Scala binary tree
/**
* D Holbrook
*
* Code Club: PO1
*
* (*) Define a binary tree data structure and related fundamental operations.
*
* Use whichever language features are the best fit (this will depend on the language you have selected). The following operations should be supported:
*
* Constructors
@swuecho
swuecho / README.md
Created October 28, 2015 17:37 — forked from estebistec/README.md
This minimal setup allows you to run nginx using the current folder as the doc-root. NOTE: python's simplehttpserver may be good enough for you. This is just a nice simple nginx setup.
  1. Get all of these files into the target folder
  2. Run the following commands:
chmod +x *.sh
./nginx-start.sh
@swuecho
swuecho / handler.js
Created September 25, 2015 21:05 — forked from ThisIsMissEm/handler.js
The better way to execute Go on Amazon Lambda (see: http://blog.0x82.com/2014/11/24/aws-lambda-functions-in-go/)
var child_process = require('child_process');
exports.handler = function(event, context) {
var proc = spawn('./test', [ JSON.stringify(event) ], { stdio: 'inherit' });
proc.on('close', function(code){
if(code !== 0) {
return context.done(new Error("Process exited with non-zero status code"));
}
@swuecho
swuecho / Linux Static IP
Last active September 21, 2015 02:22 — forked from fernandoaleman/Linux Static IP
How To Configure Static IP On CentOS 6
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static
@swuecho
swuecho / mandelbrot.sql
Last active August 29, 2015 14:25 — forked from rupey/mandelbrot.sql
Mandelbrot plot in postgres
WITH RECURSIVE
x(i) AS ( VALUES (0)
UNION ALL SELECT i + 1
FROM x
WHERE i < 101),
Z(Ix, Iy, Cx, Cy, X, Y, I) AS (
SELECT
Ix,
Iy,
X :: FLOAT,
fn main() {
let player_scores = [
("Jack", 20), ("Jane", 23), ("Jill", 18), ("John", 19),
];
let players = player_scores
.iter()
.map(|&(player, _score)| {
player
})
fn main() {
let mut teams = [
[ ("Jack", 20), ("Jane", 23), ("Jill", 18), ("John", 19), ],
[ ("Bill", 17), ("Brenda", 16), ("Brad", 18), ("Barbara", 17), ]
];
let teams_in_score_order = teams
.iter_mut()
.map(|team| {
team.sort_by(|&a, &b| a.1.cmp(&b.1));
// This code is editable and runnable!
fn main() {
// A simple integer calculator:
// `+` or `-` means add or subtract by 1
// `*` or `/` means multiply or divide by 2
let program = "+ + * - /";
let mut accumulator = 0;
for token in program.chars() {