Skip to content

Instantly share code, notes, and snippets.

View foursixnine's full-sized avatar
♾️
Dreaming about maria cookies!

Santiago Zarate foursixnine

♾️
Dreaming about maria cookies!
View GitHub Profile
@drmalex07
drmalex07 / getopt-example.sh
Last active April 18, 2024 21:39
A small example on Bash getopts. #bash #getopt #getopts
#!/bin/bash
#
# Example using getopt (vs builtin getopts) that can also handle long options.
# Another clean example can be found at:
# http://www.bahmanm.com/blogs/command-line-options-how-to-parse-in-bash-using-getopt
#
aflag=n
bflag=n
@jaredhirsch
jaredhirsch / gist:4971859
Created February 17, 2013 15:19
all about ETags

ETags: a pretty sweet feature of HTTP 1.1

HTTP caching review

HTTP provides two ways for servers to control client-side caching of page components:

  • freshness may be based on a date or a token whose meaning is app-specific
  • whether or not the client needs to confirm the cached version is up-to-date with the server

This breaks down as follows:

  • Cache locally and don't check before using.
@mapix
mapix / xinitrc
Created January 28, 2013 02:10
xinitrc for multi-monitor display in i3-wm
#!/bin/sh
#
# ~/.xinitrc
# Executed by startx (run your window manager from here)
# Set up screens and set background
if [ `xrandr | grep -c ' connected '` -eq 2 ]; then # dual-monitor
if [ `xrandr | grep VGA-1 | grep -c ' connected '` -eq 1 ]; then
xrandr --output LVDS-1 --auto --primary --output VGA-1 --auto --right-of LVDS-1
fi
# install fsarchiver
# In Fedora/RedHat system's :: yum install fsarchiver sfdisk dd
# In Debian/Ubuntu System :: apt-get install fsarchiver sfdisk dd
DEVICE_TO_BACKUP=/dev/sdb # assuming /dev/sda is where you have booted ur primary OS
mkdir ./backup_with_fsarchiver # create a directory
cd ./backup_with_fsarchiver # enter into newly created directory
# only get the first 512 bytes # read mbr in wiki for more details
dd if=$DEVICE_TO_BACKUP of=mbr count=1 bs=512
sfdisk -d $DEVICE_TO_BACKUP > partition.sfdisk
@dmkash
dmkash / br.sh
Created April 10, 2012 22:44
Shell Script for tmux setup
#!/bin/sh
SESSION_NAME="big_red"
cd ~/Sites/within3/big_red
tmux has-session -t ${SESSION_NAME}
if [ $? != 0 ]
then
@jamband
jamband / sample.php
Last active August 19, 2016 23:14
Yii Framework: example LIKE query.
<?php
$c = new CDbCriteria();
Hoge::model()->findAll($c);
// SELECT * FROM `hoge` `t`
$c = new CDbCriteria();
$c->addSearchCondition('t.fuga', null); // null, false, ''などは無視されるようです
Hoge::model()->findAll($c);
@gaubert
gaubert / .lftp.mockup.rc
Created February 11, 2011 08:56
~/.lftp.rc parameters detailed
########## SETTINGS
# On startup, lftp executes ~/.lftprc and ~/.lftp/rc. You can place aliases and 'set' commands
# there. Some people prefer to see full protocol debug, use 'debug' to turn the debug on.
# Certain commands and settings take a time interval parameter. It has the format Nx[Nx...], where N is time amount
# (floating point) and x is time unit: d - days, h - hours, m - minutes, s - seconds. Default unit is second. E.g.
# 5h30m or 5.5h. Also the interval can be 'infinity', 'inf', 'never', 'forever' - it means infinite interval. E.g.
# 'sleep forever' or 'set dns:cache-expire never'.