Skip to content

Instantly share code, notes, and snippets.

View TheRatG's full-sized avatar
🐭
be balanced

Vladimir Pak TheRatG

🐭
be balanced
View GitHub Profile
@TheRatG
TheRatG / perl replace
Last active August 29, 2015 14:07
perl replace
perl -i -p -e 's/search/replace/' filename;
@TheRatG
TheRatG / chmod
Last active August 29, 2015 14:08
Uni read privileges
find <folder> -type d -exec chmod 755 {} \;
find <folder> -type f -exec chmod 644 {} \;
@TheRatG
TheRatG / git revert
Created December 17, 2012 08:02
git revert
Try this first:
git checkout master
(If you're on a different branch than master, use the branch name there instead.)
If that doesn't work, try...
For a single file:
git checkout HEAD /path/to/file
@TheRatG
TheRatG / Find and replace
Last active December 9, 2015 23:49
Find and replace
find ./ -type f -exec sed -i 's/find/replace/g' {} \;
Run all tests
```python
#file __init__.py
def load_tests(loader, standard_tests, pattern):
# top level directory cached on loader instance
this_dir = os.path.dirname(__file__) + '/tests'
package_tests = loader.discover(start_dir=this_dir, pattern=pattern)
standard_tests.addTests(package_tests)
return standard_tests
```
@TheRatG
TheRatG / gist:8612616
Created January 25, 2014 06:36
Disable cache file
What you're seeing is probably because the server serving the static files is using the "sendfile()" syscall, which is broken with the VirtualBox file system. You need to disable sendfile() usage in your server. For Apache:
EnableSendfile off
And for nginx:
sendfile off;
@TheRatG
TheRatG / find and size
Last active January 27, 2016 07:38
find and size
# find old files and calculate their size in Mb
find ./logs/* -type f -mtime +180 -exec du -ks {} \; | cut -f1 | awk '{total=total+$1}END{print total/1024}'
@TheRatG
TheRatG / Replace in big file
Created June 20, 2016 06:43
Replace in big file
perl -e 'BEGIN{$/=\32768}' -pe "s/a/b/g" < one-line-250-mb.txt
@TheRatG
TheRatG / extract_phar.sh
Last active November 15, 2016 07:18
Extract phar
#!/usr/bin/env bash
#extract phar
phar extract -f php_util.phar extracted
#how to check is in phar
#if (strpos(__DIR__, 'phar://') === 0) {}
@TheRatG
TheRatG / mac_os_tips.md
Last active January 30, 2017 07:34
Mac OS

SSH Broken Pipe fix

Source

To fix it, on your mac do:

emacs (or vim/vi/nano/etc) ~/.ssh/config

And then, write this: