This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# sort on perl subs, can be changed to any other token for any other language | |
TOKEN=sub | |
gsed -e ':a;N;$!ba;s/\n/__newline__/g' "$1" > "$1.out" | |
gsed -i "s/__newline__\\s*$TOKEN\W/\\nsub /g" "$1.out" | |
sort $1.out -o $1.out | |
gsed -i 's/__newline__/\n/g' $1.out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use strict 'vars'; | |
use feature qw/say/; | |
my $date_from = &date_to_int( 'Oct', '14', '20', '00', '00'); | |
my $date_to = &date_to_int( 'Oct', '15', '21', '00', '00'); | |
while ( <DATA> ) { | |
chomp; | |
my ($month, $day, $hour, $min, $sec, $server, $msg) = $_ =~ m/(\w+) (\d+) (\d+):(\d+):(\d+) (\w+) (.*)/; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import math | |
from BeautifulSoup import BeautifulSoup | |
def distance_on_unit_sphere(lat1, long1, lat2, long2): | |
"src: http://www.johndcook.com/python_longitude_latitude.html" | |
degrees_to_radians = math.pi/180.0 | |
phi1 = (90.0 - lat1)*degrees_to_radians | |
phi2 = (90.0 - lat2)*degrees_to_radians |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# More information can be found; | |
# - http://dev.mysql.com/doc/refman/5.1/en/load-data.html | |
# - http://dev.mysql.com/doc/refman/5.5/en/optimizing-innodb-bulk-data-loading.html | |
SET autocommit=0;SET unique_checks=0;SET foreign_key_checks=0; | |
LOAD DATA INFILE IGNORE 'my_data.csv' INTO TABLE my_table | |
COMMIT;SET unique_checks=1;SET foreign_key_checks=1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip install sqlacodegen | |
pip install MySQL-python | |
sqlacodegen mysql://www:www@localhost/db_name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Usage | |
# copy_ssh_keys.sh user@host | |
# | |
# Notes | |
# Makes sure to generate your ssh keys before running, if | |
# you havent done so just uncomment the line below | |
# ssh-keygen -t rsa | |
echo -e "\n>>> Creating remote .ssh folder" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
# This is an example of how to print a console | |
# message on the same line | |
from time import sleep | |
import sys | |
def ps(string): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
# This is an example of how to print a console | |
# message on the same line | |
from time import sleep | |
import sys | |
def ps(string): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
# This is an example of how to print a console | |
# message on the same line | |
from time import sleep | |
import sys | |
def ps(string): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# encoding: utf-8 | |
# This is an example of how to print a console | |
# message on the same line | |
from time import sleep | |
import sys | |
def ps(string): |