Skip to content

Instantly share code, notes, and snippets.

View rcanepa's full-sized avatar

Renzo Canepa rcanepa

  • Santiago, Chile
View GitHub Profile
@rcanepa
rcanepa / nginx.conf
Created December 21, 2016 15:03 — forked from Stanback/nginx.conf
Example Nginx configuration for adding cross-origin resource sharing (CORS) support to reverse proxied APIs
#
# CORS header support
#
# One way to use this is by placing it into a file called "cors_support"
# under your Nginx configuration directory and placing the following
# statement inside your **location** block(s):
#
# include cors_support;
#
# As of Nginx 1.7.5, add_header supports an "always" parameter which
@rcanepa
rcanepa / gist:e20c23a8f7c140f37ea8a04cf593dbe8
Created November 21, 2016 20:43
Reformatt Clojure code on Spacemacs
cider-format-edn-region
ls /bin/ /usr/bin/ | tee >(grep x > x_files) | sort | uniq | grep wr
^ ^ output the ones with an wr in their name
from the list of all binaries, save to x_files the ones that contains and x in their name
cat data.txt | tee >(pbcopy) >(do_stuff) >(do_more_stuff) | grep important-stuff
^ ^ ^
redirect the content of data.txt to three different tasks
@rcanepa
rcanepa / gist:f47dd80d4ae7bb3c3858f93a33d2a177
Created October 7, 2016 20:47
Unix - Check permissions along a path
[root@alter-facturacion var]# namei -lom /var/www/simpleclerk/backoffice/index.html
f: /var/www/simpleclerk/backoffice/index.html
dr-xr-xr-x root root /
drwxr-xr-x root nginx var
drwxr-xr-x root nginx www
drwxr-xr-x root nginx simpleclerk
drwxr-xr-x root nginx backoffice
-rwxr-xr-x root nginx index.html
Symbolic Notation Numeric Notation English
---------- 0000 no permissions
-rwx------ 0700 read, write, & execute only for owner
-rwxrwx--- 0770 read, write, & execute for owner and group
-rwxrwxrwx 0777 read, write, & execute for owner, group and others
---x--x--x 0111 execute
--w--w--w- 0222 write
--wx-wx-wx 0333 write & execute
-r--r--r-- 0444 read
-r-xr-xr-x 0555 read & execute
@rcanepa
rcanepa / gist:4c16c43e91eee90f10138e8625afcdc1
Created September 8, 2016 23:37
Find references to namespace alias http on all namespaces
find . -iname "*.clj" |
xargs grep -ho -e "http\/.*" |
cut -d ' ' -f 1 |
sed 's/)//g' |
sort |
uniq
http/bad-request
http/conflict
http/content-type
@rcanepa
rcanepa / angular_watcher_counter.md
Created September 7, 2016 02:03
Counting watchers on AngularJS

This Immediately Invoked Function Expression (IIFE) will print out the number of watchers currently on the page. Simply paste it into the console to see how many watchers are currently on the page. This IIFE was taken from Words Like Jared's answer on StackOverflow: http://stackoverflow.com/questions/18499909/how-to-count-total-number-of-watches-on-a-page

(function () { 
    var root = $(document.getElementsByTagName('body'));
    var watchers = [];

    var f = function (element) {
 if (element.data().hasOwnProperty('$scope')) {
@rcanepa
rcanepa / gist:1905dba16031171bb06f315868fc892e
Last active September 10, 2016 22:05
Bash key shortcuts
Moving the cursor:
Ctrl + a Go to the beginning of the line (Home)
Ctrl + e Go to the End of the line (End)
Ctrl + p Previous command (Up arrow)
Ctrl + n Next command (Down arrow)
Alt + b Back (left) one word
Alt + f Forward (right) one word
Ctrl + f Forward one character
Ctrl + b Backward one character
Ctrl + xx Toggle between the start of line and current cursor position
@rcanepa
rcanepa / gist:8a334d7c4f46df948c676aab489fe2c2
Last active June 28, 2024 12:39
Undo committed files (move them back to the staging area without cancelling changes)
- Reset current branch to the parent of HEAD
git reset --soft HEAD~
- Reset the unwanted files in order to leave them out from the commit:
git reset HEAD path/to/unwanted_file
- Commit again using the same commit message:
git commit -c ORIG_HEAD
(*) git reset --soft HEAD~
@rcanepa
rcanepa / vim.md
Last active June 11, 2018 19:53
Vim tips

Buffers

List open buffers:

:ls

Open buffer by file name:

:b <buffer-name>