Skip to content

Instantly share code, notes, and snippets.

<meta name=”viewport” content=”width=device-width, initial-scale=1.0″ />
<style>
/* ———–Smartphone View———– */
@media only screen and (max-width : 800px) {
/* All smartphone rules go inside here */
}
/* ———–Tablet View———– */
@media only screen and (max-width : 1180px) and (min-width : 801px) {
@adamneilson
adamneilson / gist:5029974
Created February 25, 2013 14:04
Swap variables values without the use of a third trivial interview question.
// set the initial values
$a = 100;
$b = 200;
// swap them!
$a = $a + $b; // $a == 300
$b = $a - $b; // $b == 100
$a = $a - $b; // $a == 200
// done!
@adamneilson
adamneilson / mentions_and_tags.clj
Last active December 17, 2015 22:39
Sample code to scan a body of text for @mentions and #tags
;=============================
; a sample body of text
;=============================
(def sample "A mention: @bob and another: \uFF20charlie but not me@home.com and #my_tag should be caught as should #another. Tests passed? #blimey!")
;=============================
; valid at chars are @ and \uFF20
;=============================
(def mention-pattern #"(^|\s)[@\uFF20](\w+)")
(def tag-pattern #"(^|\s)#(\w+)")
@adamneilson
adamneilson / tumblr_gist_iphone_fix.css
Last active December 18, 2015 00:09
Gists don't seem to display correctly on an iPhone when embedded in a Tumblr post. After a bit of digging I've cobbled together the following CSS which seems to fix the issue.
/** corrections for displaying gists in iOS **/
.gist {
font-family: Consolas,"Liberation Mono",Courier,monospace;
font-size: 12px !important;
line-height:20px !important;
}
.gist .line,
.gist .line-number {
font-family: Consolas,"Liberation Mono",Courier,monospace;
font-size: 12px !important;
(let [conn (langohr.core/connect)]
(comment do-stuff))
(langohr.core/connect {
:username "harvey"
:password "Elwood"
:host "bunny.junkey.com"
:virtual-host "/"
:port 5672
:type "direct"
:exchange "sorting-room"
:queue "po-box"
:durable true
##################################
## ROUTE WWW TO ROOT FOR SEO
##################################
server {
listen 80;
server_name www.junkey.com;
# forward everything from www.junkey.com to junkey.com
return 301 $scheme://junkey.com$request_uri;
}
@adamneilson
adamneilson / gist:7230370
Created October 30, 2013 10:31
Generates available domain names
#!/usr/bin/python -O
import random
import string
import subprocess
import threading
import time
# get a list of words with only ASCII characters, and surround them with ^ and $ to demarcate the word boundaries
words = [w.strip().lower() for w in open("/usr/share/dict/words").readlines()]
words = ["^" + w + "$" for w in words if w != "" and all([c in string.ascii_lowercase for c in w])]
@adamneilson
adamneilson / the.css
Last active December 27, 2015 22:09
Keep varying shaped images looking sweet in a grid (for junkey)
.thumb-container {
width: 266px;
height: 177px;
overflow: hidden;
position: relative;
}
.thumb {
position: absolute;
}
[
;; ----- User type -----
{:db/id #db/id[:db.part/db]
:db/ident :user/name
:db/valueType :db.type/string
:db/cardinality :db.cardinality/one
:db/doc "A users name"
:db/unique :db.unique/identity