Skip to content

Instantly share code, notes, and snippets.

Avatar

Zak El Fassi zakelfassi

View GitHub Profile
@zakelfassi
zakelfassi / lastEdited.sh
Created Feb 15, 2016
Get Last 1000 edited files in Unix
View lastEdited.sh
find . -type f -printf '%T@ %p\n' | sort -n | tail -1000 | cut -f2- -d" "
View update_paperclip_attachements.rb
# Assuming you had a model like this
#
# class Post
# has_attached_file :image, :path => ":rails_root/public/system/:attachment/:id/:style/:filename"
# end
namespace :paperclip do
desc "Recreate attachments and save them to new destination"
task :move_attachments => :environment do
View gist:d9d7870e30d21d2cf213
# GIT Tricks.
Delete from git all deleted system files:
git rm $(git ls-files --deleted)
View deleted file:
git show HEAD^:path/to/file
git show $(git rev-list --max-count=1 --all -- foo)^:foo
View ansible.yml
---
- name: Deploy new site release
user: deployer
hosts: all
tasks:
- name: Fetch repo updates
git: >
repo=git@github.com:my/repo.git
View count-lines.sh
# Count lines in a files (zsh, bash)
cat big-file.sql | sed '/^\s*$/d' | wc -l
# Count result of search ...
grep 'something' big-file.sql | sed '/^\s*$/d' | wc -l
View capybaraSheatSheet.md

Capybara Cheat Sheet

Navigating

visit('/projects')
visit(post_comments_path(post))

Clicking links and buttons

@zakelfassi
zakelfassi / android_shortcut.java
Created Apr 10, 2014
Create android app shortcut programatically
View android_shortcut.java
// Note that a shortcut is created automagically if the app is installed via Play store.
// Change "APP_NAME" by your app name. *MrObvious*
/*Manifest file - add this */
<uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" />
/* MainActivity.java */
public class MainActivity ... {
...
private SharedPreferences appSettings;
View tmux_cheatsheet.markdown

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with Unicode (to remove annoying empty space corruption while running zsh):

@zakelfassi
zakelfassi / gist:8676166
Created Jan 28, 2014
Rollback a `git commit`
View gist:8676166
Undo a commit and redo
$ git commit ... (1)
$ git reset --soft 'HEAD^' (2)
$ edit (3)
$ git add .... (4)
$ git commit -c ORIG_HEAD (5)
This is what you want to undo
This is most often done when you remembered what you just committed is incomplete, or you misspelled your commit message, or both. Leaves working tree as it was before "reset". (The quotes may or may not be required in your shell)
@zakelfassi
zakelfassi / .htaccess-redirect
Created Dec 21, 2013
Super PHP site redirection.
View .htaccess-redirect
<IfModule mod_rewrite.c>
Options +FollowSymlinks
RewriteEngine on
rewritecond %{http_host} ^OLD_SITE.com [nc]
rewriterule ^(.*)$ http://NEW_SITE.com/$1 [r=301,nc]
</IfModule>