Skip to content

Instantly share code, notes, and snippets.

View jrwren's full-sized avatar
๐Ÿ’ญ
๐Ÿคฏ๐Ÿ’ฏ๐Ÿ‘๐Ÿ”ฅ๐ŸŽ‰๐Ÿคทโ€โ™€๏ธ๐Ÿ˜๐Ÿ˜•๐Ÿ•ด๐Ÿฝ๐Ÿ˜ต๐Ÿ˜ž๐Ÿค•๐Ÿคฎ

Jay R. Wren jrwren

๐Ÿ’ญ
๐Ÿคฏ๐Ÿ’ฏ๐Ÿ‘๐Ÿ”ฅ๐ŸŽ‰๐Ÿคทโ€โ™€๏ธ๐Ÿ˜๐Ÿ˜•๐Ÿ•ด๐Ÿฝ๐Ÿ˜ต๐Ÿ˜ž๐Ÿค•๐Ÿคฎ
View GitHub Profile
$ nodejs
> a = /\[:[^\]]+:]/g
/\[:[^\]]+:]/g
> b = /\[#[^\]]+#]/g
/\[#[^\]]+#]/g
> test = " shit, [: bitch :] i'm gonna [# kill #] that [# fuked #] ass"
' shit, [: bitch :] i\'m gonna [# kill #] that [# fuked #] ass'
> test.match(a)
[ '[: bitch :]' ]
> test.match(b)
@jrwren
jrwren / gist:5257136
Created March 27, 2013 19:11
mmap(via boost mapped_file_source) + linux kernel cache is fast
jrwren@delays:{%5}~/src/mmaptest $ ./trmm
25.449077s wall, 1.610000s user + 1.250000s system = 2.860000s CPU (11.2%)
2048MB at 80.4745 MB/s
Checksum: 8740270876149790436
jrwren@delays:{%5}~/src/mmaptest $ ./trmm
2.157940s wall, 1.500000s user + 0.650000s system = 2.150000s CPU (99.6%)
2048MB at 949.06 MB/s
Checksum: 8740270876149790436
$ python
Python 2.7.2 (default, Oct 11 2012, 20:14:37)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import logging
>>> console=logging.StreamHandler()
>>> logging.getLogger("").addHandler(console)
>>> logging.getLogger("").info('hi')
>>> logging.getLogger("").warn('hi')
hi
@jrwren
jrwren / gist:6030832
Created July 18, 2013 16:40
my git config
$ cat ~/.gitconfig
[user]
name = Jay R. Wren
email = jrwren@xmtp.net
[color]
ui = auto
[alias]
st = status
done = commit -m 'fuckit, git-r-done'
$ azure vm create jrwtest b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-12_04_3-LTS-amd64-server-20130916.1-en-us-30GB jwren --location "East US" -e -t id_rsa.PKCS8.pem
info: Executing command vm create
+ Looking up image
+ Looking up cloud service
warn: --location option will be ignored
+ Getting cloud service properties
+ Looking up deployment
+ Retrieving storage accounts
Enter VM 'jwren' password: ******
Confirm password: ******
@jrwren
jrwren / fucked
Last active December 24, 2015 07:29
how I would do it.
code behind:
public IEnumerable<Tuple<int, string, string>> Images;
Page_Load() {
Images = Telerik.Sitefinity.App.WorkWith().Images().Where(
w => w.Album.Title == imgLibrary && w.Status == Telerik.Sitefinity.GenericContent.Model.ContentLifecycleStatus.Live).Get().Select(
(item, index) => Tuple.Create(index,"../../" + item.Description.Value, item.ItemDefaultUrl + ".jpg")
);
...
@jrwren
jrwren / fail
Created October 1, 2013 14:01
things I cannot remember
$ python -m SimpleHTTP
python: No module named SimpleHTTP
$ python -m SimpleHttp
python: No module named SimpleHttp
$ python -m SimpleHttpServer
python: No module named SimpleHttpServer
$ python -m SimpleWebServer
python: No module named SimpleWebServer
$
... write this gist to clear my head... then...
@jrwren
jrwren / gist:6819662
Created October 4, 2013 01:26
lower case http headers?
$ curl -I http://t.co/IIvchRkvGc
HTTP/1.1 301 Moved Permanently
cache-control: private,max-age=300
date: Fri, 04 Oct 2013 01:25:30 GMT
expires: Thu, 01-Jan-1970 00:00:00 GMT
location: http://www.geekgirldiva.com/2013/10/um-did-you-know-someone-makes-star-trek.html
server: tfe
set-cookie: muc=1;Domain=t.co;Expires=Wed, 16-Sep-2015 01:25:30 GMT
Content-Length: 0
When I open vim this is what I see:
bad ass code, starin at me
I've got lambdas in my head
and I ain't afraid to show it...
I'm coding and they know it.
@jrwren
jrwren / server.yaml
Created October 21, 2013 16:17
debian python-boto package doesn't ship the "bins" so fetch_file and s3put are not there. Write quick and dirty versions of them. Then fetch the last database from s3 and restore it. add an hourly cron job to dump the database and put to s3.
#cloud-config
runcmd:
- |
echo "#!/usr/bin/python
import boto, sys
boto.connect_s3().get_bucket(sys.argv[0]).get_key(sys.argv[1]).get_contents_to_filename(sys.argv[2])
">/usr/bin/s3get
- chmod +x /usr/bin/s3get
- s3get bucket db_dumps/$HOSTNAME-dbname.pg_dump /var/tmp/dbname.pg_dump
- su -c 'pg_restore -d dbname /var/tmp/dbname.pg_dump' postgres