Skip to content

Instantly share code, notes, and snippets.

@swaroopch
swaroopch / init.el
Last active September 4, 2017 13:53
Ethereum price ticker for Spacemacs mode line
;; Screenshot at https://twitter.com/swaroopch/status/903442255796633600
;; Inspired by https://www.reddit.com/r/ethtrader/comments/6wxizf/single_best_feature_of_the_new_macbook/
;; Code written for Spacemacs, will need adaptation to your Emacs setup
;; Spacemacs users: You may need to enable `spacemacs-misc` layer to ensure `request` package is installed.
(defun dotspacemacs/user-config ()
"Configuration function for user code.
This function is called at the very end of Spacemacs initialization after
layers configuration.
This is the place where most of your configurations should be done. Unless it is
@swaroopch
swaroopch / init.el
Last active September 1, 2017 01:03
How do I add a new segment to the spacemacs mode line?
(spaceline-define-segment foo
"Foo Docs"
(when (bound-and-true-p spaceline-foo-p)
"Foo: TODO")
:when active
:global-override foo)
(add-to-list 'spacemacs-spaceline-additional-segments '(foo))
(spaceline-spacemacs-theme '(foo))
@swaroopch
swaroopch / readme.md
Last active August 16, 2017 17:47 — forked from anoff/readme.md
Readme Template

MyTool {Title/Reponame}

Helps you build things {one-line purpose}

{} = Explanations for this readme..

Maybe here is a small overview of how MyTool, should not be longer than 5 lines and you're invited to use emojis 👯.

#!/usr/bin/env python
from __future__ import absolute_import, division, print_function, unicode_literals
import arrow
import click
click.disable_unicode_literals_warning = True
def is_weekend(i):
assert isinstance(i, arrow.Arrow)
@swaroopch
swaroopch / spacemacs.org
Last active March 11, 2017 20:23
spacemacs-org-present
@swaroopch
swaroopch / expose.sh
Created November 8, 2012 07:03
(not working) How to expose a local server to the outside world via an EC2 server?
# Before: I have a local Java or Django server running on port 8000
function expose_port {
local_port=$1
shift
ssh -vvv -i "$HOME/.ssh/aws.pem" -N -R "9000:localhost:8000" "ubuntu@ec2-12-34-56-789.compute-1.amazonaws.com"
}
@swaroopch
swaroopch / core.clj
Created September 26, 2012 11:23
Figuring out how to use Monger (Clojure MongoDB library) with multiple databases
(ns scratchpad.core
(:require [monger.core :as mg]
[monger.collection :as mc]
[monger.query :as mq]))
(def local-mongodb
(.getDB (mg/connect-via-uri! "mongodb://127.0.0.1:27017/local") "local"))
@swaroopch
swaroopch / TestJedis.java
Created April 17, 2012 13:58
Testing Jedis (Java Redis API) for parallel requests
// https://github.com/xetorthio/jedis
import redis.clients.jedis.Jedis;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@swaroopch
swaroopch / output.txt
Created February 15, 2012 20:25
Receive and close web request ASAP, process data later
→ python server.py
Run after this server starts : curl http://127.0.0.1:5000/?test=1
[2012-02-15 12:24:34,716] [werkzeug] [INFO] * Running on http://127.0.0.1:5000/
[2012-02-15 12:24:34,717] [werkzeug] [INFO] * Restarting with reloader
Run after this server starts : curl http://127.0.0.1:5000/?test=1
[2012-02-15 12:24:36,459] [root] [INFO] Received data ImmutableMultiDict([('test', u'1')])
[2012-02-15 12:24:36,460] [root] [INFO] Closing connection!
[2012-02-15 12:24:36,460] [werkzeug] [INFO] 127.0.0.1 - - [15/Feb/2012 12:24:36] "GET /?test=1 HTTP/1.1" 200 -
[2012-02-15 12:24:36,460] [root] [INFO] In separate process, doing something with data {'test': [u'1']}
@swaroopch
swaroopch / client.py
Created February 3, 2012 06:48
Two Legged OAuth API server (not working)
#!/usr/bin/env python
import oauth2 as oauth # pip install oauth2
parameters = {
'oauth_version' : '1.0',
'oauth_nonce' : oauth.generate_nonce(),
'oauth_timestamp' : oauth.generate_timestamp(),
}