Skip to content

Instantly share code, notes, and snippets.

View slmyers's full-sized avatar
💯
crushing code

Steven Myers slmyers

💯
crushing code
View GitHub Profile
package com.myproject.cassandraloading;
import static com.google.common.collect.Iterables.filter;
import static com.google.common.collect.Iterables.transform;
import java.io.File;
import java.lang.management.ManagementFactory;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.nio.ByteBuffer;
@slmyers
slmyers / springer-free-maths-books.md
Created December 28, 2015 19:42 — forked from bishboria/springer-free-maths-books.md
Springer have made a bunch of maths books available for free, here are the direct links
@slmyers
slmyers / redis-eventsource.go
Created January 4, 2016 23:13 — forked from jweir/redis-eventsource.go
Example of using Redis PubSub and EventSource with golang
package main
import (
eventsource "github.com/antage/eventsource/http"
redis "github.com/vmihailenco/redis"
"log"
"net/http"
)
func haltOnErr(err error){
@slmyers
slmyers / redux-simple-router-example.tsx
Created January 5, 2016 02:16 — forked from jasonswearingen/redux-simple-router-example.tsx
A simplified example of redux + redux-simple-router using Typescript
/**
WHAT: A very simple example of redux + redux-simple-router using Typescript.
WHY: The official example found here: https://github.com/rackt/redux-simple-router/tree/1.0.2/examples/basic has problems:
1) it is spread over many files making it very hard to "skim"
2) it is organized by function, not by feature. (Example: learning "how to manipulate redux state" is spread over 5 files in 4 folders)
3) there are no comments explaining what's going on/why.
WHO: by JasonS@Novaleaf.com
@slmyers
slmyers / active-record-migration-expert.md
Created February 18, 2016 19:03 — forked from pyk/active-record-migration-expert.md
become active record migration expert (Rails 4.0.2)

become active record migration expert (Rails 4.0.2)

workflow:

create model

$ rails g model NameOfModel
    invoke  active_record
    create    db/migrate/YYYYMMDDHHMMSS_create_name_of_models.rb

Difference between Debounce and Throttle

Debounce

Debounce a function when you want it to execute only once after a defined interval of time. If the event occurs multiple times within the interval, the interval is reset each time.
Example A user is typing into an input field and you want to execute a function, such as a call to the server, only when the user stops typing for a certain interval, such as 500ms.

Throttle

const cache = {}
export default getJSONWithCache(url) {
return cache[url] ?
Promise.resolve(cache[url]) :
getJSON(url).then(json => {
cache[url] = json
return json
})
}
@slmyers
slmyers / mutex.js
Last active June 2, 2016 18:36 — forked from artursapek/mutex.js
// Originally taken from https://github.com/mgtitimoli/await-mutex
class Mutex {
constructor() {
this._locking = Promise.resolve();
this._locked = false;
}
isLocked() {
return this._locked;
interface Position {
left:string;
top: string;
}
@Component({
selector: 'drag-demo',
template: `
<div #target [ngStyle]="boxPosition | async">drag me</div>
`
})
@slmyers
slmyers / lumen.lua
Created March 18, 2017 19:27 — forked from anonymous/lumen.lua
Self-hosted Lisp using vvander's Lua browser runtime: https://cdn.rawgit.com/vvanders/wasm_lua/d68f46a8/main.html
environment = {{}}
target = "lua"
function nil63(x)
return(x == nil)
end
function is63(x)
return(not nil63(x))
end
function no(x)
return(nil63(x) or x == false)