Skip to content

Instantly share code, notes, and snippets.

View skyrocknroll's full-sized avatar

Yuvaraj L skyrocknroll

View GitHub Profile
#!/bin/bash
# by TB : 2012-10-12
if [ "$USER" != "root" ]
then
echo "You must be root to execute this script (in order to instruct the kernel to drop the cache)!"
exit 1
fi
if [ -z "$1" ]
#!/bin/bash
# node.js using PPA (for statsd)
sudo apt-get install python-software-properties
sudo apt-add-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm
# Install git to get statsd
sudo apt-get install git
<!DOCTYPE html>
<html>
<head>
<title>Test Swift CORS</title>
<!-- Only using jQuery for jQuery.parseJSON -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<body>
<div style="border: thin solid grey; padding-left: 10px; width: 50%; margin-left: auto; margin-right: auto">
'''
PIL's Image.thumbnail() returns an image that fits inside of a given size (preserving aspect ratios)
but the size of the actual image will vary and is certainly not guaranteed to be the requested size.
This is often inconvenient since the size of the returned thumbnail cannot be predicted. The django-thumbs
library solves this for square thumbnails by cropping the image to a square and then resizing it. However,
this only works for exact squares.
This function generalizes that approach to work for thumbnails of any aspect ratio. The returned thumbnail
is always exactly the requested size, and edges (left/right or top/bottom) are cropped off to adjust to
make sure the thumbnail will be the right size without distorting the image.
@skyrocknroll
skyrocknroll / INSTALL.md
Last active December 27, 2015 18:39 — forked from mat/INSTALL
graphite statsd installation seyren

https://github.com/gingerlime/graphite-fabric

Fabric file to install all the graphite and statsd

TODO:

  • edit /opt/statsd/local.js
    • correct the graphite host to localhost
    • if desired, put 'debug: true' in there
  • make the box accessible via the hostname 'graphite'

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
@skyrocknroll
skyrocknroll / latency.txt
Created January 27, 2014 18:52 — forked from jboner/latency.txt
latency numbers
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
[solarized-dark]
background = #002b36
foreground = #839496
majorLine = #fdf6e3
minorLine = #eee8d5
lineColors = #268bd2,#859900,#dc322f,#d33682,#db4b16,#b58900,#2aa198,#6c71c4
fontName = Sans
fontSize = 10
fontBold = False
fontItalic = False
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
@skyrocknroll
skyrocknroll / remove pyc from git
Last active August 29, 2015 14:02 — forked from fjunior87/remove pyc from git
remove pyc from git
find . -name "*pyc" -exec git rm -f {} \;