Skip to content

Instantly share code, notes, and snippets.

View KCreate's full-sized avatar
🍰
the cake is a lie

Leonard Schütz KCreate

🍰
the cake is a lie
View GitHub Profile
@KCreate
KCreate / asyncAlert.js
Created November 22, 2015 11:51
Asynchronous JavaScript Alert
function asyncAlert(m){
setTimeout(function(){
alert(m);
},1);
};
@KCreate
KCreate / solver.coffee
Created December 9, 2015 15:11
playcodemonkey.com universal solver
[bananas].map (item) ->
item.map (item) ->
item.defaultValues=monkey.defaultValues
@KCreate
KCreate / objectmap.js
Created January 11, 2016 07:28
Object map functions
/*
Iterate over an object
*/
Object.prototype.map = function(cb) {
Object.keys(this).map(function(item) {
if (this.hasOwnProperty(item)) {
this[item] = cb(item, this[item], this);
}
}.bind(this));
return this;
@KCreate
KCreate / EasyQuery.php
Created February 26, 2016 08:59
EasyQuery
// Easier sql queries
class EasyQuery {
private $dbname;
private $db;
public function __construct($dbname) {
$this->dbname = $dbname;
// Check if the db file exists
if (!file_exists($this->dbname)) {
@KCreate
KCreate / Inverter.js
Created March 26, 2016 20:43
React inverter
var Inverter = React.createClass({
getInitialState: function() {
return {
text: ""
};
},
textChange: function(event) {
this.setState({
text: event.target.value
});
@KCreate
KCreate / get.js
Last active April 25, 2016 21:27
xhr request wrapper
export default function get(url, method, options, _callback) {
// Allow the options to be optional
if (typeof options == 'function') {
_callback = options;
options = {};
}
// Wrap the _callback
const callback = function(err) {
@KCreate
KCreate / setup.sh
Created May 7, 2016 22:23
Personal Ubuntu Setup Script
# Install git
sudo apt-get install git
sudo mkdir ~/github/
# Uninstall all previous copies of vim
sudo apt-get remove --purge vim vim-runtime vim-gnome vim-tiny vim-common vim-gui-common
sudo apt-get build-dep vim-gnome
sudo apt-get install python-dev libncurses5-dev
sudo rm -rf /usr/local/share/vim
sudo rm /usr/bin/vim
@KCreate
KCreate / header.scss
Last active May 13, 2016 19:52
Exponential decay headers in scss
$decrease: 4;
$initial: 28;
@for $i from 1 through 6 {
> h#{$i} {
// Formula: https://www.desmos.com/calculator/dhrvkbio8f
font-size: 1px * ($initial - (2 * $decrease)) + (pow($decrease, 2) / pow(2, $i));
}
@if $i < 6 {
> h#{$i} + h#{$i+1} {
@KCreate
KCreate / microsoft.js
Created June 22, 2016 07:41
How the microsoft marketing team generates new names.
const microsoft = function(name) {
const microsoft = (Math.random() < 0.5) ? 'microsoft ' : '';
const smart = (Math.random() < 0.5) ? 'smart ' : '';
const center = (Math.random() < 0.5) ? ' center' : '';
const fullname = microsoft + smart + name + center;
return fullname.trim();
}
module.exports = microsoft;
const leftpad = require('left-pad');
const fs = require('fs');
const chars = [
[
'┌─┐',
'│ │',
'│ │',
'│ │',
'└─┘',