Skip to content

Instantly share code, notes, and snippets.

@s4wny
s4wny / backend.php
Last active Nov 18, 2015
ajax autocomplete tutorial
View backend.php
<?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 Oct 21, 2015
Install a ubuntu webserver
View install-webserver.sh
sudo apt-get update
##
## NGINX
##
sudo apt-get install nginx -y
@s4wny
s4wny / dell display manager command line documentation
Created Oct 10, 2015
dell display manager command line documentation
View 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 Feb 14, 2016
Server setup
View setup.sh
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 Feb 8, 2017
Git hooks/post-receive
View post-receive.sh
#!/bin/bash
WORKSPACE=/var/www/html/
echo "Post-receive"
git --work-tree=$WORKSPACE checkout -f
cd $WORKSPACE
@s4wny
s4wny / debug.php
Last active Aug 29, 2015
Debug function for PHP
View debug.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 Aug 29, 2015
Haskell 99 problems.hs
View 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 Mar 29, 2015
Haskell buildsystem with error message for sublime text 3
View haskell.sublime-build
{
"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 Dec 26, 2015
Animate things without jQuery
View Animator.js
// 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 Dec 21, 2015
Sublimetext in the browser.
View gist:6234637

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>
You can’t perform that action at this time.