Skip to content

Instantly share code, notes, and snippets.

View akinsho's full-sized avatar

Akin akinsho

  • London
View GitHub Profile
const isUnique = (array) => array.length === new Set(array).size;
@akinsho
akinsho / gist:c11af0a10605247368356f22dee33fcf
Created May 24, 2017 20:31
generate and index to us to loop through an array endlessly
function crawlArray(array, index, n) {
return ((index + n) % array.length + array.length) % array.length;
}
@akinsho
akinsho / gist:71f6bc6fd91e22a5b724e14a1d083dc7
Created May 14, 2017 23:01
Get month in human speak JS
var date = new Date("10/11/2009"),
locale = "en-us",
month = date.toLocaleString(locale, { month: "long" });
@akinsho
akinsho / client.js
Created April 21, 2017 23:11 — forked from crtr0/client.js
A simple example of setting-up dynamic "rooms" for socket.io clients to join
// set-up a connection between the client and the server
var socket = io.connect();
// let's assume that the client page, once rendered, knows what room it wants to join
var room = "abc123";
socket.on('connect', function() {
// Connected, let's sign-up for to receive messages for this room
socket.emit('room', room);
});
@akinsho
akinsho / gist:0a15f84b139ee27557a9a132cdad12fd
Created April 14, 2017 17:03
The compose function used in Redux
/**
* Composes single-argument functions from right to left. The rightmost
* function can take multiple arguments as it provides the signature for
* the resulting composite function.
*
* @param {...Function} funcs The functions to compose.
* @returns {Function} A function obtained by composing the argument functions
* from right to left. For example, compose(f, g, h) is identical to doing
* (...args) => f(g(h(...args))).
language: node_js
node_js:
- "6.9.5"
# addons:
# postgresql: "9.5"
before_script:
- "psql -c 'create database lmao_test;' -U postgres"
- "psql -U postgres -d lmao_test -a -f database/db_build.sql"
script:
- "npm run coverage"
@akinsho
akinsho / gist:669d640d1de07839688a4b7b6a30da03
Created April 3, 2017 18:03 — forked from mikeal/gist:1840641
get a new/clean port with node.js
var portrange = 45032
function getPort (cb) {
var port = portrange
portrange += 1
var server = net.createServer()
server.listen(port, function (err) {
server.once('close', function () {
cb(port)
@akinsho
akinsho / gist:f8a9387e62822889ab9f5540f5cfe5a0
Created March 27, 2017 23:58
Vimscript func to use tab for autocompletion with Ultisnips
function! s:check_back_space()
let col = col('.') - 1
return !col || getline('.')[col - 1] =~ '\s'
endfunction
let g:ulti_expand_res = 0 "default value, just set once
function! Tab_Snippet_Complete()
let snippet = UltiSnips#ExpandSnippet()
if g:ulti_expand_res > 0
return snippet
@akinsho
akinsho / b.rb
Created February 15, 2017 21:26 — forked from junegunn/b.rb
b - browse Chrome bookmarks with fzf
#!/usr/bin/env bash
# vim: set filetype=ruby:
# b - browse Chrome bookmarks with fzf
[ $(uname) = Darwin ] || exit 1
which fzf > /dev/null 2>&1 || brew reinstall --HEAD fzf || exit 1
/usr/bin/ruby -x "$0" |
fzf-tmux -u 30% --ansi --multi --no-hscroll --tiebreak=begin |
awk 'BEGIN { FS = "\t" } { print $2 }' |
@akinsho
akinsho / macbook-setup.md
Created February 9, 2017 23:43 — forked from justinsoliz/macbook-setup.md
Set Up Zsh, Presto, Homebrew, Ruby, Powerline, and Vim on Mac OS X

blog about these tools

Setup Zsh and Prezto

  • Change default shell to Zsh
chsh -s $(which zsh)
  • Clone Presto and install it according to README.md