Skip to content

Instantly share code, notes, and snippets.

@paulvictor
paulvictor / replier.rb
Created July 10, 2012 16:13
Facebook birthday replier
#!/usr/bin/env ruby
require 'rest-client'
require 'json'
require 'time'
require 'date'
at = ENV['access_token']
if at.nil?
$stderr.write 'go get an access token at https://developers.facebook.com/tools/explorer/ with permissions to read your birthday, feed and post on your behalf'
exit 1
end
@paulvictor
paulvictor / shows
Created July 12, 2012 07:23
Tv shows from FB
#!/usr/bin/env ruby
require 'csv'
require 'rest-client'
require 'json'
CSV.foreach("./tv_shows.csv") do |row|
begin
name = row[1]
row[1].gsub!(/ /, "+")
puts("https://graph.facebook.com/search?until=yesterday&q=#{row[1]}&type=page")
@paulvictor
paulvictor / twitter_tv_shows
Created July 12, 2012 11:15
Tv show pages from twitter
#!/usr/bin/env ruby
require 'csv'
require 'json'
require 'oauth'
class Credentials
def self.next
@@read_creds ||= CSV.foreach("./creds.csv") do |row|
@@vals ||= []
@@vals << {:consumer_key => row[0], :consumer_secret => row[1], :token => row[2], :secret => row[3]}
@paulvictor
paulvictor / tmux.conf
Created July 16, 2012 07:05
tmux conf
# From http://alexyoung.org/2011/12/19/build-an-ide-with-tmux-and-vim/
set-window-option -g mode-keys vi
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R
bind-key -rn C-h select-window -t :-
bind-key -rn C-l select-window -t :+
set -g default-terminal "screen-256color"
@paulvictor
paulvictor / zpop.rb
Created August 30, 2012 07:53
Ruby script for a Redis zpop
require 'redis'
get_and_rem_script = <<EOF
local resp = redis.call('zrangebyscore', KEYS[1], '-inf', '+inf', 'LIMIT', '0', '1');
if (resp[1] ~= nil) then
local val = resp[# resp]
redis.call('zrem', KEYS[1], val)
return val
else
return false
@paulvictor
paulvictor / id_rsa.pub
Created July 2, 2014 04:31
Paul's public key
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDs/OqkjP+BkZAqppcifbiK93yFd4QznkbY7NVVrt4VaQFwn24X66I0h5k1b+e4TPBA5KHP1iZPMYlX22TCg/zu2H7ldoEANbQO2HgOnQttkYg0y3y14FEQ3i2URohASaMsKV6+SMse3Eg8RN6Am2V8xQbZDxE3XFbddamCWfcLDEeMnf7sVhmSB5d1p1X/KioeZJTbP8bq/F2UXscbXybQBLwv6jjptgfiKmuHAvzVIV8vjk3AClOKkweFb/AONNqfQQZkRXUvaqbgjo3US1VYiBApz3JbQk6rlbOlwRWmQVJegRZmegng+qyD8/+nK2dLzKiYsG2UgLnbG60orGfZ [email protected]
@paulvictor
paulvictor / ObservableT.js
Created January 28, 2016 09:06
Demonstrate how to use monadTransformers to combine monads(Observerable and IO in this case) to form higher order monads
"use strict"
var m = require("monet");
var MonadT = m.MonadT;
var IO = m.IO;
var Observable = require("rx").Observable;
class IOObs {
constructor(ioObservable){
this.value = ioObservable;
}
@paulvictor
paulvictor / ObservableEither.js
Created February 18, 2016 06:51
Monad Transformer combining Observable and Either to handle non-determinism, async and error handling
"use strict"
var R = require("ramda");
var Sequelize = require("sequelize");
var Either = require("fantasy-eithers");
var Left = Either.Left
var Right = Either.Right
var Observable = require("rx").Observable;
var rx = require("rx");
var EitherHelpers = require("fantasy-contrib-either")
@paulvictor
paulvictor / cvimrc
Last active February 5, 2019 06:51
My temporary cvimrc
set nohud
set smoothscroll
"set noautofocus " The opposite of autofocus; this setting stops
" sites from focusing on an input box when they load
set typelinkhints
set dimhintcharacters
let scrollstep = 70
let zoomfactor = 0.1
let scrollduration = 350
let searchlimit = 500
@paulvictor
paulvictor / gist:e8625977cda8e4d8a10cde90e9dbd87e
Created February 22, 2017 09:18
Monadic composition of screens
flow = do
_ <- splashScreen
l <- languageSet
pure(l ? npciSplashScreen : ChooseLanguageScreen)
npciSplashScreen = do
_ <- wait 0
permission <- checkPermission
pure(permission ? postPermission : showPermission)