Skip to content

Instantly share code, notes, and snippets.

View dvcrn's full-sized avatar
💫

David dvcrn

💫
View GitHub Profile
@dvcrn
dvcrn / bot.py
Created October 2, 2011 11:38
SpaceSphere - A Twitter Autoreply Bot
#!/usr/bin/env python
import sys
from twython import Twython
import random
CONSUMER_KEY = 'xxxx'
CONSUMER_SECRET = 'xxxx'
ACCESS_KEY = 'xxxx'
ACCESS_SECRET = 'xxxx'
@dvcrn
dvcrn / sina.py
Created September 25, 2012 03:05
Bing download url crawler
from pybing import Bing
from urllib2 import HTTPError
from BeautifulSoup import BeautifulSoup
from pybing import constants
import re
import mechanize
import simplejson
searchstring = "cows" # your search string here
searchcount = 40
@dvcrn
dvcrn / gist:3847689
Created October 7, 2012 09:43
Parse twitter urls, hashtags and usernames
parse_tweet = function (str) {
var create_link = function (url, text) {
var link = $("<a>", {
text: text,
href: url,
target: "_blank"
});
return link.prop('outerHTML');
};
@dvcrn
dvcrn / proxmate.me s3 prerender
Created March 16, 2014 16:31
prerender script used for generating static pages for proxmate.me.
fs = require 'fs'
webpage = require 'webpage'
page = webpage.create()
renderedUrls = 0
totalUrls = 0
# Taken from https://github.com/ariya/phantomjs/blob/master/examples/waitfor.js
# Converted into coffee
waitFor = (testFx, onReady, timeOutMillis) ->
maxtimeOutMillis = (if timeOutMillis then timeOutMillis else 5000) #< Default Max Timout is 3s
@dvcrn
dvcrn / gist:95b42a5c7c61860ea2af
Created June 16, 2015 16:15
Launch Emacs.app or create a new window if already running
emacs () {
PROCESS=Emacs
number=$(ps aux | grep $PROCESS | wc -l)
if [ $number -gt 1 ]
then
emacsclient -c -n $1
else
open -a /usr/local/Cellar/emacs-mac/emacs-24.5-z-mac-5.8/Emacs.app $1
fi
@dvcrn
dvcrn / gist:d3b1fe416c017499ddfa
Created July 6, 2015 09:09
linear regression with 1 variable in python
testset = [
[1, 4],
[2, 8],
[3, 12],
[4, 16]
]
theta0 = 0
theta1 = 0
learningrate = 0.01
@dvcrn
dvcrn / reagent-animated-example.cljs
Last active January 31, 2023 01:08
reagent react-native animation example
;; very simple example on how to use Animated with reagent
;; https://facebook.github.io/react-native/docs/animations.html
(def animated (.-Animated js/React))
(def animated-value (.-Value animated))
(def animated-view (r/adapt-react-class (.-View animated)))
(defn testview []
(r/create-class
@dvcrn
dvcrn / keybase.md
Created August 29, 2016 07:53
keybase.md

Keybase proof

I hereby claim:

  • I am dvcrn on github.
  • I am dvcrn (https://keybase.io/dvcrn) on keybase.
  • I have a public key ASD90ukgjRDay6u9VaMUG_WeXf4xhzUAhUVgaG7Di83jzwo

To claim this, I am signing this object:

@dvcrn
dvcrn / main.cljs
Created December 29, 2016 08:12
realm example in clojurescript
(def Realm (js/require "realm"))
;; define dog schema
(def dog {:name "Dog"
:properties {:name "string"
:age "int"}})
;; instantiate Realm with the dog schema
(def r (Realm. (clj->js {:schema [dog]})))
@dvcrn
dvcrn / mona.applescript
Last active November 20, 2017 20:29
Fetch crypto price in applescript
# example to fetch the current MONA price in JPY
# needs http://www.mousedown.net/mouseware/JSONHelper.html
# replace 'neo' with any other ID supported by coinmarketcap
# using coinmarketcaps convert API to add `price_jpy` to the result
set json_data to (do shell script "curl https://api.coinmarketcap.com/v1/ticker/monacoin/?convert=JPY")
tell application "JSON Helper"
set json_data to read JSON from json_data
end tell