Skip to content

Instantly share code, notes, and snippets.

View cms's full-sized avatar

Christian C. Salvadó cms

View GitHub Profile
@bmarston
bmarston / InitialDbMigrationCommand.php
Created May 8, 2013 16:23
Let's say you're starting a new Yii project and you've already created the database schema for it using something like phpMyAdmin or MySQL Workbench. Now you want to create an initial database migration so you can put the schema under version control, but you don't want to manually write the Yii code to create the tables, indexes, and foreign ke…
<?php
class InitialDbMigrationCommand extends CConsoleCommand
{
public function run($args) {
$schema = $args[0];
$tables = Yii::app()->db->schema->getTables($schema);
$addForeignKeys = '';
$dropForeignKeys = '';
@jpouellet
jpouellet / zbell.sh
Last active November 24, 2023 10:49
Makes Zsh print a bell when long-running commands finish. I use this in combination with i3 and throw big compile jobs (or whatever it may be) into another workspace to get a nice visual notification (workspace indicator turns red) when it's done so I don't need to waste time regularly checking on it.
#!/usr/bin/env zsh
# This script prints a bell character when a command finishes
# if it has been running for longer than $zbell_duration seconds.
# If there are programs that you know run long that you don't
# want to bell after, then add them to $zbell_ignore.
#
# This script uses only zsh builtins so its fast, there's no needless
# forking, and its only dependency is zsh and its standard modules
#
@tarruda
tarruda / .README.md
Last active September 27, 2021 13:21
Tmux/Vim integration

Some scripts/configurations that greatly improve tmux/vim workflows. The shell scripts target zsh but should be adaptable without much effort for other unix shells.

Features:

  • Transparently move between tmux panes and vim windows
  • Using the shell, open files in one vim instance per project or directory
  • Fully integrated copy/paste between tmux, vim and x11 using simple keybinds(need to install the xclip program)
  • Easily send text to any tmux pane without breaking your edit workflow(needs slimux

'vim-tmux-move.zsh', '.vimrc' and '.tmux.conf' cooperate so you can move transparently between tmux panes and vim windows using ALT + (arrow keys or jkhl). It was based on this gist

@sindresorhus
sindresorhus / git-dirty-checks.md
Created October 16, 2012 11:20
Benchmark results of the fastest way to check if a git branch is dirty

Tested against the WebKit git repo by entering the repo with 1 file dirty.


git diff --quiet --ignore-submodules HEAD # Will tell if there are any uncomitted changes, staged or not.
0.6 sec

git diff-index --quiet HEAD # Only tracked
2 sec

@agnoster
agnoster / README.md
Last active April 6, 2024 22:35
My ZSH Theme

agnoster.zsh-theme

A ZSH theme optimized for people who use:

  • Solarized
  • Git
  • Unicode-compatible fonts and terminals (I use iTerm2 + Menlo)

For Mac users, I highly recommend iTerm 2 + Solarized Dark

@pasela
pasela / screen-4.1.0-cygwin-sock-permission.patch
Created August 20, 2012 05:40
GNU screen: A patch to avoid /tmp/uscreens permission check on Cygwin
diff --git a/src/screen.c b/src/screen.c
index 6e19732..3a8ca3e 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -1102,8 +1102,10 @@ char **av;
n = (eff_uid == 0 && (real_uid || (st.st_mode & 0775) != 0775)) ? 0755 :
(eff_gid == (int)st.st_gid && eff_gid != real_gid) ? 0775 :
0777;
+#if !defined(__CYGWIN__)
if (((int)st.st_mode & 0777) != n)
@bigeasy
bigeasy / OSXScreen.md
Created April 7, 2012 10:12
How to install GNU Screen on OS X using Homebrew.

Installing GNU Screen on OS X in Homebrew

I want to edit in one tab, run what I edit in the other. Typical multi-view stuff. I've used Terminal.app for the last few years. Lately, however, after not long enough, Terminal gets laggy when I switch between tabs.

The stutter between edit and run is annoying, an unnacceptable. One of the major reason I've chosen to work with character based UI is because it is snappy. There shouldn't be a lag while a screen of UTF-8 is rendered in a monospace font.

The lag gets progressively longer, chipping at my productivity with irritation. The only solution is to kill all my Terminals, which essentially kills my flow. Terminal.app won't remember where I was for me. I have to initialize ever tab.

GNU Screen

@yevgenko
yevgenko / .Xdefaults
Created August 24, 2011 02:58
URxvt settings with solarized theme
!-------------------------------------------------------------------------------
! Xft settings
!-------------------------------------------------------------------------------
Xft.dpi: 96
Xft.antialias: false
Xft.rgba: rgb
Xft.hinting: true
Xft.hintstyle: hintslight
@cms
cms / es3-es5-incompatibilities.js
Created October 27, 2010 18:55
List of ES3 Incompatibilities introduced by ES5
/*
* List of ES3 Incompatibilities introduced by ES5.
*
*/
/*
* From Annex E:
*/