Skip to content

Instantly share code, notes, and snippets.

@s4wny
s4wny / backend.php
Last active November 18, 2015 17:37
ajax autocomplete tutorial
<?php
$mysqli = new mysqli('localhost', 'test', 'test', 'test');
if($mysqli->connect_errno)
exit("Connect failed: %s\n". $mysqli->connect_error);
$stmt = $mysqli->prepare("SELECT name FROM states WHERE name LIKE ?");
if($stmt) {
@s4wny
s4wny / install-webserver.sh
Last active October 21, 2015 18:39
Install a ubuntu webserver
sudo apt-get update
##
## NGINX
##
sudo apt-get install nginx -y
@s4wny
s4wny / dell display manager command line documentation
Created October 10, 2015 18:59
dell display manager command line documentation
===============================================
Dell Display Manager
===============================================
Command language
-----------------------------------
A rich and flexible command language is supported via the
command-line, and command-line arguments can be combined.
Where appropriate, a specific display can be targeted by
prefacing the command with the display number, e.g.,
@s4wny
s4wny / setup.sh
Last active February 14, 2016 18:59
Server setup
sudo apt-get update
##
## Security
##
# Only allow key based logins (BE SURE TO SET UP SSH KEYS BEFORE EXECUTING THIS)
sed -n 'H;${x;s/\#PasswordAuthentication yes/PasswordAuthentication no/;p;}' /etc/ssh/sshd_config > tmp_sshd_config
@s4wny
s4wny / post-receive.sh
Last active February 8, 2017 18:44
Git hooks/post-receive
#!/bin/bash
WORKSPACE=/var/www/html/
echo "Post-receive"
git --work-tree=$WORKSPACE checkout -f
cd $WORKSPACE
@s4wny
s4wny / debug.php
Last active August 29, 2015 14:18
Debug function for PHP
<?php
// Source: http://stackoverflow.com/a/19788805/996028
// Author: Mark Baker
/*
* Skriver ut i det här formatet:
* *namnet på $var*:
* var_dump
*
@s4wny
s4wny / Haskell 99 problems.hs
Last active August 29, 2015 14:17
Haskell 99 problems.hs
import Data.List
import System.Random
import Control.Applicative
import Control.Monad.Writer
-- 1
myLast :: [a] -> a
myLast [x] = x
myLast (_:xs) = myLast xs
@s4wny
s4wny / haskell.sublime-build
Created March 29, 2015 11:34
Haskell buildsystem with error message for sublime text 3
{
"cmd": ["runhaskell", "$file"],
"file_regex": "(\\w:[^:]+):([0-9]+):([0-9]+)",
"selector": "source.hs",
"path": "c:\\Program Files\\Haskell Platform\\2014.2.0.0\\bin\\"
}
@s4wny
s4wny / Animator.js
Last active December 26, 2015 16:39
Animate things without jQuery
// Original code from http://gabrieleromanato.name/javascript-implementing-the-fadein-and-fadeout-methods-without-jquery/
// Modified by Sony? aka Sawny
var Animator = {
// Uses "jQuery" style / standard style. So you can easly import easings from jQuery
// or other resources
//
// Format:
// percent | elapsed time | start value | end value | total duration
// x | t | b | c | d
@s4wny
s4wny / gist:6234637
Last active December 21, 2015 02:19
Sublimetext in the browser.

Copy and paste this into the browsers URL bar.

Protip: Bookmark it ;)

data:text/html,<link rel="shortcut icon" href="http://g.etfv.co/http://www.sublimetext.com"/><title>:)</title><style type="text/css">#e{font-size: 16px; position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/javascript");</script>