Skip to content

Instantly share code, notes, and snippets.

@phpdude
phpdude / nginx.conf
Last active February 28, 2024 04:36
Nginx image filter + caching of results.
location /resize {
alias /tmp/nginx/resize;
set $width 150;
set $height 100;
set $dimens "";
if ($uri ~* "^/resize_(\d+)x(\d+)/(.*)" ) {
set $width $1;
set $height $2;
set $image_path $3;
@i-e-b
i-e-b / A_Profile_BJSS.ps1
Last active October 28, 2023 13:27
My sample Powershell profile script
Set-PSReadlineOption -BellStyle None
# Clone `https://github.com/dahlbyk/posh-git.git` to C:\Gits
Import-Module 'C:\Gits\posh-git\src\posh-git.psd1'
set-executionpolicy Unrestricted process
$baseDir = Split-Path -parent $MyInvocation.MyCommand.Definition
#. "$baseDir\hand.ps1"
# General actions
function edit ($file) { & "${env:ProgramFiles(x86)}\Notepad++\notepad++.exe" $file }
@alejandrobernardis
alejandrobernardis / handlers.py
Created February 10, 2012 16:55
Tornado, Download File
class AdminFileHandler(BaseHandler):
@authenticated
def get(self, file_name):
_file_dir = os.path.abspath("")+"/my/path/downloads"
_file_path = "%s/%s" % (_file_dir, file_name)
if not file_name or not os.path.exists(_file_path):
raise HTTPError(404)
self.set_header('Content-Type', 'application/force-download')
self.set_header('Content-Disposition', 'attachment; filename=%s' % file_name)
@sharoonthomas
sharoonthomas / gist:2785473
Created May 25, 2012 02:52
Serve files based on google authentication
#! /usr/bin/env python
# -*- coding: utf-8 -*-
"""
Authentication proxy for Tornado to use Google apps authentication to
serve the files in a protected location. Ideal to serve files like
sphinx documentation behind a password.
:copyright: (c) 2011 by Openlabs Technologies & Consulting (P) Limited
:license: BSD, see LICENSE for more details.
"""
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 23, 2024 18:01
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@jamescasbon
jamescasbon / example.py
Created June 20, 2012 21:27
Tornado github API client
import tornado.ioloop
import tornado.web
import tornado.escape
import tornado.options
import tornado.httputil
import jinja2
import pyjade.compiler
import coffeescript
import markdown
@squioc
squioc / gist:3078803
Created July 9, 2012 20:49
conversion between iso8601 date format and unix epoch datetime
from datetime import datetime
import calendar
def epoch_to_iso8601(timestamp):
"""
epoch_to_iso8601 - convert the unix epoch time into a iso8601 formatted date
>>> epoch_to_iso8601(1341866722)
'2012-07-09T22:45:22'
"""
@jshaw
jshaw / underscore-template-conditional.js
Created July 19, 2012 13:55
Underscore.js template conditional example
// If URL is available URL link the image
// Otherwise just display the image
<% if ( instagram_link_url ) { %> <a href="<%= instagram_link_url %>" target="_blank"> <% } %>
<img src="<%= url %>" alt="<%= username %>" />
<% if ( instagram_link_url ) { %> </a> <% } %>
// Example 2 - Check if formated date
<% if (typeof(date) != "undefined") { %>
<span class="date"><%= date %></span>
<% } %>
@certik
certik / Output
Created August 14, 2012 23:12
Unicode in Fortran
Ondřej Čertík
@hazelnusse
hazelnusse / Makefile
Created August 28, 2012 07:10 — forked from certik/README.md
C vs Fortran benchmark
all : a_f a_c a_c++
a_f : a.f90
gfortran -O3 -march=native -ffast-math -funroll-loops a.f90 -o a_f
a_c : a.c
gcc -O3 -march=native -ffast-math -funroll-loops a.c -o a_c
a_c++ : a.cc
g++ -O3 -march=native -ffast-math -funroll-loops a.cc -o a_c++