Skip to content

Instantly share code, notes, and snippets.

View chaosmail's full-sized avatar

Christoph Koerner chaosmail

View GitHub Profile
@chaosmail
chaosmail / gist:9016290
Created February 15, 2014 08:41
Copy SSH Key to Ubuntu 12.04 LTS
ssh user@server.com
ssh-keygen -t rsa
exit
cat ~/.ssh/id_rsa.pub | ssh user@server.com 'cat >> ~/.ssh/authorized_keys'
<!DOCTYPE html>
<html>
<head>
<title>
My first demo
</title>
<!-- Link the Bootstrap css -->
<link href="components/bootstrap/dist/css/bootstrap.css" rel="stylesheet">
@chaosmail
chaosmail / crawler.py
Created July 15, 2014 14:31
Simple Webcrawler
from bs4 import BeautifulSoup
import urllib.request
url = "http://www.google.com/"
res = urllib.request.urlopen(url)
html = res.read()
soup = BeautifulSoup(html)
print(soup)
@chaosmail
chaosmail / crawler.js
Created July 15, 2014 16:22
Simple PhantomJS Crawler
var system = require('system');
var fs = require('fs');
var args = system.args;
if (args.length === 1) {
console.log("Please write url as argument");
phantom.exit();
}
console.log('Loading', args[1]);
@chaosmail
chaosmail / performance.py
Created October 11, 2014 18:00
Check performance of loops and arrays in Python
from __future__ import print_function
import cProfile
import random
num_elems = 1000000
test = [random.randint(1,100) for i in range(num_elems)]
print("Loops\n*******")
print("Range and Len")
@chaosmail
chaosmail / import_database_mysql.sh
Created November 8, 2014 13:11
Import a Database in MySQL with the Comandline
mysql -u root -p -h localhost database_name < backup.sql
@chaosmail
chaosmail / automake_python
Last active September 30, 2015 12:31
Python Makefile
# Project Setup
pkg_name = MoreSpaceEducation
venv_dir = .venv
src_dir = $(pkg_name)
python = python3.4
# Declare the tools
pkgm = pip
venv = virtualenv --no-site-packages --distribute -p /usr/bin/$(python)
test = pytest
@chaosmail
chaosmail / default.ooxml
Last active October 20, 2015 20:36
Ooxml File
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><?mso-application progid="Word.Document"?><pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage"><pkg:part pkg:name="/_rels/.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:padding="512"><pkg:xmlData><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml" /></Relationships></pkg:xmlData></pkg:part><pkg:part pkg:name="/word/_rels/document.xml.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml" pkg:padding="256"><pkg:xmlData><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/webSettings" Target="webSettings.xml" /><Relationship Id="rId7" Type="http://schemas.openxmlformats.org
@chaosmail
chaosmail / PHP.isSerialized
Created March 28, 2013 16:34
Check if String is serialized
function isSerialized($string) {
return (@unserialize($string) !== false);
}
@chaosmail
chaosmail / PHP.encodeHtml
Created March 28, 2013 16:37
UTF-8 Encode HTML-String
function encodeHtml($string) {
return htmlentities($string, ENT_QUOTES, "utf-8");
}