Skip to content

Instantly share code, notes, and snippets.

@miped
miped / tmux-cheatsheet.markdown
Created February 6, 2022 17:06 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
import sublime
import sublime_plugin
class ToggleVintageous(sublime_plugin.WindowCommand):
def run(self):
setts = sublime.load_settings('Preferences.sublime-settings')
ignored = setts.get('ignored_packages')
launch_status = False
@miped
miped / Traceback
Created July 9, 2013 21:02
Package Control proxy connection header error
Package Control: Fetching list of available packages
Platform: linux-x64
Sublime Text Version: 3047
Package Control Version: 2.0.0-alpha7
theme loaded
Package Control: Unable to find a sublime-package file for SublimeGit
Package Control: Unable to find file package-metadata.json in the package SublimeGit
Package Control: Download Debug
URL: http://release.sublimegit.net/SublimeGit.sublime-package
Resolved IP: 192.155.92.235
@miped
miped / packing.py
Created April 22, 2013 20:25
Brute force side by side by "splitting" the box into two halves
def side_by_side_brute(items):
# can all the books fit?
if max_height(items) > MAX_HEIGHT or max_width(items) > MAX_WIDTH:
return False
# is the volume ok?
if total_volume(items) >= MAX_HEIGHT * MAX_WIDTH * MAX_DEPTH:
return False
# we are dealing with factorials here... 10! is 3.6 mio options
@miped
miped / packing.py
Created April 22, 2013 19:39
Simple packing algorithm for flat-ish things
def side_by_side_simple(items):
if max_height(items) > MAX_HEIGHT or max_width(items) > MAX_WIDTH:
return False
if total_depth(items) <= MAX_DEPTH:
return True
pairs = permutations(items, 2)
stackable_pairs = []
for a, b in pairs:
stackable = False
@miped
miped / magento
Created March 8, 2013 12:28
nginx + php-fpm magento setup
# /etc/nginx/sites-enabled/magento
server {
listen 80;
server_name ec2-184-72-68-219.compute-1.amazonaws.com;
root /var/www/magento/;
access_log /var/log/nginx/magento-access_log;
error_log /var/log/nginx/magento-error_log;
location / {
@miped
miped / nginx.conf
Created February 11, 2013 11:07
Example deployment of flask app
upstream qrr_app {
server 127.0.0.1:8080 fail_timeout=0;
}
server {
listen 80;
server_name app.qrr.dk;
keepalive_timeout 5;
@miped
miped / jsontest.go
Created January 28, 2013 21:03
Splitter in go?!?
package main
import (
"encoding/json"
"fmt"
)
type DatetimeCondition struct {
From *float32
To *float32
@miped
miped / payment.js
Created January 20, 2013 13:43
Correct that shit
if (expiry_month.length == 1) {
expiry_month = '0' + expiry_month;
$('.card-expiry-month').val(expiry_month);
}
if (expiry_year.length == 2) {
expiry_year = '20' + expiry_year;
$('.card-expiry-year').val(expiry_year);
}
@miped
miped / payment.js
Last active December 11, 2015 09:09
Test for major credit card types
function detect_card_type(card_number) {
if (!_.isString(card_number) || _.isEmpty(card_number.trim())) {
return null;
}
c = card_number.trim();
// http://en.wikipedia.org/wiki/List_of_Issuer_Identification_Numbers
if (/^[1-2]/.test(c)) return 'airline';
if (/^3[06]/.test(c)) return 'diners';
if (/^3[47]/.test(c)) return 'amex';