Skip to content

Instantly share code, notes, and snippets.

View tjoskar's full-sized avatar

Oskar Karlsson tjoskar

View GitHub Profile
@tjoskar
tjoskar / db.py
Last active December 21, 2015 00:19
A simple db class that let you create raw sql calls in a nicer way (Active record style).
""" DB class """
"""
A simple db class that let you create raw sql calls in a nicer way.
The result is cached until reset() or select() is called.
Eg.
db.select('id', 'table AS t1').run()
db.join('join_table AS t2', 't1.id = t2.t1_id').run() // Gives the same result as above (if it didn't return null) because reset() is never called
db.select('id', 'table AS t1').join('join_table AS t2', 't1.id = t2.t1_id').run() // Gives the wanted result
db.select('id', 'table AS t')
@tjoskar
tjoskar / css.css
Last active December 20, 2015 15:09
Simpel corner to coner animation
.holder {
position: absolute;
left: 0;
top: 0;
background: red;
white-space: nowrap;
-webkit-animation: frames 30s linear;
}
@-webkit-keyframes frames {
@tjoskar
tjoskar / 404.html
Last active December 20, 2015 15:08
Standard 404 page
<!DOCTYPE html>
<html>
<head>
<style>
body {
-webkit-font-smoothing: antialiased;
background-repeat:repeat;
background-color: #26a9e0;
background-image:url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHhtbG5zOnhsaW5rPSdodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rJyB3aWR0aD0nNDkxLjk5OTk5OTk5OTk5OTk0JyBoZWlnaHQ9JzI1Mi4wMDAwMDAwMDAwMDAwMycgdmlld0JveD0nMCAwIDk4LjM5OTk5OTk5OTk5OTk5IDUwLjQwMDAwMDAwMDAwMDAwNic+Cgk8ZGVmcz4KCQk8cGF0aCBpZD0ncycgZmlsbD0nI2ZmZmZmZicgZD0nTTAsMGw4IDRsLTgsNHonLz4KCTwvZGVmcz4KCTxnIGlkPSdiJz4KCTx1c2UgeD0nLTgnIHk9Jy00JyB0cmFuc2Zvcm09J21hdHJpeCgtMSAwIDAgMSAwIDApJyBmaWxsLW9wYWNpdHk9JzAuMycgeGxpbms6aHJlZj0nI3MnIC8+Cgk8dXNlIHg9JzAnIHk9JzAuMicgZmlsbC1vcGFjaXR5PScwLjQ0OTk5OTk5OTk5OTk5OTk2JyB4bGluazpocmVmPScjcycgLz4KCTx1c2UgeD0nLTgnIHk9JzQuNCcgdHJhbnNmb3JtPSdtYXRyaXgoLTEgMCAwIDEgMCAwKScgZmlsbC1vcGFjaXR5PScwLjQ0OTk5OTk5OTk5OTk5OTk2JyB4bGluazpocmVmPScjcycgLz4KCTx1c2UgeD0nMCcgeT0nOC42JyBmaWxsLW9wYWNpdHk9JzAuNDQ5OTk5OTk5OTk5OTk5OTYnIHhsaW5rOmhyZWY
@tjoskar
tjoskar / gist:6139571
Last active December 20, 2015 13:29
Disable cache in firefox
Open FF config page by typing "about:config" in the address bar
Search for ‘network.http.use-cache’ and double click on the line.
The value should now be false
That was all folks
@tjoskar
tjoskar / NAME.js
Last active December 20, 2015 05:38
Common javascript structure for small JS project
var NAME = {
log: function(msg) {
console.log(msg);
},
error: function(msg) {
console.error(msg);
},
time: function() {
return new Date().getTime();
},

Setup django using apache2 and MySQL (Ubuntu)

Install mod_wsgi for apache2.

$ sudo apt-get install libapache2-mod-wsgi

Install pythons mysql connector.

@tjoskar
tjoskar / ssh_keys_osx.md
Last active December 18, 2015 13:18 — forked from trey/ssh_keys_osx.md

Distribute your ssh keys


If your remote username is different from your OS X username, edit your ~/.ssh/config file like so:

Host whathaveyou.com
    User remote_username

Generating your keys

Create a JS Object with Overwritable Settings

var Fancy = {
	settings: {
		something: 'one',
		somethingElse: 'two'
	},
	init: function(options){
 var s = $.extend({}, this.settings, options);

Basic MySQL Commands (that you should know)

Create a database.

$ mysqladmin -u[username] create [database name]

Alt.

$ CREATE DATABASE my_db;
@tjoskar
tjoskar / enable_codecoverage.md
Created June 6, 2013 14:01
How enable xdebug and codecoverage for MAMP and phpunit

How enable xdebug and codecoverage for MAMP and phpunit


First, edit your php.init file

$ sublime /Applications/MAMP/bin/php/php5.x.xx/conf/php.ini

(You can find your php version by "php -v" and the path by "which php")