Skip to content

Instantly share code, notes, and snippets.

@digitup
digitup / git Post-update
Created August 17, 2012 18:40
Git: post update script
#!/bin/sh
#
# This hook does two things:
#
# 1. update the "info" files that allow the list of references to be
# queries over dumb transports such as http
#
# 2. if this repository looks like it is a non-bare repository, and
# the checked-out branch is pushed to, then update the working copy.
# This makes "push" function somewhat similarly to darcs and bzr.
@digitup
digitup / jQuery.fix.element.pos.after.scroll.js
Created November 3, 2012 19:40
jQuery - Fix Element Position After Some Scroll Using jQuery
(function($){
$.fn.scrollFixed = function(params){
params = $.extend( {appearAfterDiv: 0, hideBeforeDiv: 0}, params);
var element = $(this);
if(params.appearAfterDiv)
var distanceTop = element.offset().top + $(params.appearAfterDiv).outerHeight(true) + element.outerHeight(true);
else
var distanceTop = element.offset().top;
@digitup
digitup / checkURLHash.js
Created December 20, 2012 14:31
JS - Check URL hash
function checkHash(backButton) {
if(window.location.hash) {
backButton = true;
} else {
backButton = false;
}
return backButton;
@digitup
digitup / mac.sh
Created November 5, 2016 18:59
Disable bunch of #$!@ in Sierra
#!/bin/bash
# This is a draft but it works
# FIRST (I don't even know if it works but we'll assume yes)
# sudo launchctl list
# sudo launchctl disable system/netbiosd
# sudo launchctl disable system/parsecd
# sudo launchctl disable system/parentalcontrols.check
# sudo launchctl disable system/airportd
@digitup
digitup / zsh.md
Created April 30, 2013 20:57 — forked from tsabat/zsh.md

Getting zsh to work in ubuntu is weird, since sh does not understand the source command. So, you do this to install zsh

wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh

and then you change your shell to zsh

chsh -s `which zsh`

and then restart

@digitup
digitup / LoadMultipleScriptsAsync.js
Created March 14, 2013 19:42
JavaScript - Load multiple 3rd party widgets asyncronously.
var script,
scripts = document.getElementsByTagName('script')[0],
scriptList = {
'plusone' : '//apis.google.com/js/plusone.js',
'twitter' : '//platform.twitter.com/widgets.js',
'someother': '//s.widgetsite.com/widget.js'
};
for (var id in scriptList) {
script = document.createElement('script');
@digitup
digitup / securePhpMyAdmin.sh
Created March 10, 2013 17:01
Server - Secure phpMyAdmin
//install phpmyadmin
sudo apt-get install phpmyadmin
//After the installation has completed, add phpmyadmin to the apache configuration.
sudo nano /etc/apache2/apache2.conf
//add phpmyadmin to config file
Include /etc/phpmyadmin/apache.conf
@digitup
digitup / database.sh
Last active December 14, 2015 18:28
Backup and restore database
rsync /var/lib/mysql root@destination.server.com:/var/lib/ -a
Or:
//Export Database
mysqldump -uUsername -p Database > db_backup.sql
 
//Export Multiple databases
mysqldump -uUsername -p --databases db_name1 [db_name2 ...] > db_backup.sql
@digitup
digitup / zip.sh
Created March 10, 2013 16:21
Server - Zip a folder
find /full_path -path '*/.*' -prune -o -type f -print | zip ~/file.zip -@