Skip to content

Instantly share code, notes, and snippets.

View raine's full-sized avatar

Raine Virta raine

View GitHub Profile
const params = U.view(['search', searchParamsL], location)
const search = U.atom(params.get().search || '')
const debouncedSearch = U.debounce(300, search)
debouncedSearch
.onValue(q => params.modify(
q ? R.assoc('search', q) : R.dissoc('search')
))
const items = U.thru(
debouncedSearch,
split :: Char -> String -> (String, String)
split c str = (start, rest)
where start = takeWhile (/= c) str
rest = dropWhile (== c) $ dropWhile (/= c) str
myWords :: String -> [String]
myWords [] = []
myWords str = start : (myWords rest)
where (start, rest) = split ' ' str
@raine
raine / connect-to-beats
Created January 2, 2018 12:20
Connect to Beats headphones from command-line
#!/usr/bin/env bash
# Requirements:
# - Add https://github.com/lapfelix/BluetoothConnector/ to $PATH
mac=`BluetoothDeviceConnector | grep 'Beats Studio³' | awk '{print $1}'`
BluetoothDeviceConnector $mac
@raine
raine / app.js
Last active October 10, 2018 11:59
Define socket.io once and use it in any view I want?
// Setup basic express server
var express = require('express');
var app = express();
// Spool up server
var server = app.listen(app.get('port'), function() {
console.log('App listening on port %d', app.get('port'));
});
// Import socket_api
This file has been truncated, but you can view the full file.
[
{"name":"Keeley Bosco","email":"katlyn@jenkinsmaggio.net","city":"Lake Gladysberg","mac":"08:fd:0b:cd:77:f7","timestamp":"2015-04-25 13:57:36 +0700","creditcard":"1228-1221-1221-1431"},
{"name":"Rubye Jerde","email":"juvenal@johnston.name","city":null,"mac":"90:4d:fa:42:63:a2","timestamp":"2015-04-25 09:02:04 +0700","creditcard":"1228-1221-1221-1431"},
{"name":"Miss Darian Breitenberg","email":null,"city":null,"mac":"f9:0e:d3:40:cb:e9","timestamp":"2015-04-25 13:16:03 +0700","creditcard":null},
{"name":"Celine Ankunding","email":"emery_kunze@rogahn.net","city":null,"mac":"3a:af:c9:0b:5c:08","timestamp":"2015-04-25 14:22:22 +0700","creditcard":"1228-1221-1221-1431"},
{"name":"Dr. Araceli Lang","email":"mavis_lehner@jacobi.name","city":"Yvettemouth","mac":"9e:ea:28:41:2a:50","timestamp":"2015-04-25 21:02:11 +0700","creditcard":"1211-1221-1234-2201"},
{"name":"Esteban Von","email":null,"city":null,"mac":"2d:e4:f0:dd:90:96","timestamp":"2015-04-25 21:47:09 +0700","creditcard":null},
{"name":"Everette Swift","em
@raine
raine / watch.sh
Last active June 8, 2016 10:40
Watch a file for updates and rsync/scp/copy it to remote server (OS X etc.)
npm install -g watchy
watchy -w file.txt -- scp file.txt user@host:path/to/dest
@raine
raine / rust-servers
Last active September 10, 2021 03:09
Simple rust server finder for command-line
#!/usr/bin/env bash
# rust-servers
#
# Simple rust server finder for command-line.
# Useful for getting the map of your server.
#
# Requirements:
# - brew install fzf
# - npm install -g ramda-cli
#!/usr/bin/env bash
aws s3api list-objects --bucket stuff --prefix photo/ --delimiter '/' |\
ramda '.CommonPrefixes' 'pluck \Prefix' 'map split "/"' 'map nth 1' -R |\
xargs -P4 -I % aws s3api list-objects --bucket stuff --prefix photo/% \
--query '{%: [sum(Contents[].Size), length(Contents[])]}' |\
ramda --slurp -R \
merge-all to-pairs \
'map -> zip-with ((k,v) -> "#k.#{it.0}:#v|g"), <[ s3_total_size s3_count ]>, it.1' \
flatten \
const app = require('app');
[
{
"name": "Afghanistan",
"code": "AF"
},
{
"name": "Åland Islands",
"code": "AX"
},
{