Skip to content

Instantly share code, notes, and snippets.

@emil10001
emil10001 / batch_sed_rename
Created November 29, 2012 18:17
Batch file rename in unix using sed
$ for file in *.exe ; do mv $file `echo $file | sed 's/\(.*\.\)exe/\1zip/'` ; done
$ for file in *.zip ; do mkdir `echo $file | sed 's/\(.*\.\)zip/\1/'` ; mv $file `echo $file | sed 's/\(.*\.\)zip/\1\//'` ; cd `echo $file | sed 's/\(.*\.\)zip/\1/'` ; unzip $file ; cd .. ; done
$ for file in *. ; do mv $file `echo $file | sed 's/\.//'` ; done
@emil10001
emil10001 / fiblist.clj
Last active December 14, 2015 11:09
This is a simple Clojure function to produce a list out of the Fibonacci sequence, using recursion.
(defn fiblist
([stop]
(cond
(< stop 0) '()
(= stop 0) '(0)
(= stop 1) '(0 1)
:else (reverse (fiblist stop '(1 0)))))
([stop fibseq]
(let [newfib (+ (first fibseq) (second fibseq))]
(if (<= stop newfib) fibseq
Note to self: If you are seeing htaccess permissions issues,
check your http conf file for the site. I had forgotten to
follow symlinks on an instance and was getting very strange
behavior with apache claiming that I didn't have permissions
to check .htaccess. I added the option to follow symlinks and
the problems went away.
Note to self:
I had a few issues installing sugarcrm. A few things to remember for next time:
* chown -R http:http sugarcrm/
* permissions, top folder 755, things that it wants as 766, set as that
* the htaccess/symlink issue noted in a related post
* watch the httpd error logs while running and fix things that are broken as they come up
* installed php/json by pecl install json (i think)
* enabled php things in /etc/php/php.ini - json.so, imap.so
* increase max post and file upload to 25M
$ mysql -u root -p
> CREATE DATABASE some_db;
> GRANT ALL PRIVILEGES ON some_db.* TO new_user@localhost IDENTIFIED BY 'SOMEPASSWORD';
> flush privileges;
// Can't sudo!
$ sudo su
sudo: must be setuid root
// Fix below
$ su
# ls -l /usr/bin/sudo
-rwxr-xr-x 2 asterisk asterisk 159K Sep 9 05:21 /usr/bin/sudo*
Displaying github gists in tumblr is not as difficult as I
have seen it written. All you need to do is use the embed code
provided by github.
If you want a single file in a gist with multiple files, simply
append ?file=<filename> at the end of the url.
E.g.
<script src="https://gist.github.com/emil10001/590636713d58cbc11b0a.js?file=classdef"></script>
@emil10001
emil10001 / MarketInstalled.java
Last active December 15, 2015 00:29
Method to test if Google Play is installed.
// credit - http://stackoverflow.com/a/13789869/974800
private boolean isGooglePlayInstalled() {
try {
ApplicationInfo info = getActivity().getPackageManager().getApplicationInfo(
"com.android.vending", 0);
return true;
} catch (PackageManager.NameNotFoundException e) {
return false;
}
return false;
sudo bash -c "iptables-save > /etc/iptables.rules"
@emil10001
emil10001 / fix_asterisk_perms.sh
Created March 24, 2013 00:33
I was having trouble with FreePBX saying 'no peer found' for an extension that I had added. The odd thing was that the extension did not appear in the /etc/asterisk dir anywhere. I looked all over and it took me several hours to land on the answer. Apparently, apache did not have the proper permissions to write to that dir, and couldn't store my…
chmod 777 /etc/asterisk/*