Skip to content

Instantly share code, notes, and snippets.

View emaillenin's full-sized avatar

Lenin emaillenin

  • Sydney, Australia
View GitHub Profile
@emaillenin
emaillenin / remove_brace.rb
Created March 9, 2014 10:35
Removes the opening and the closing brace using regex
"(hey there!)".gsub(/^\(|\)$/,'')
@emaillenin
emaillenin / my_bash_profile.sh
Last active August 29, 2015 14:01
my_bash_profile.sh
# Inspired from https://gist.github.com/selvakn/358558
export HISTORYFILESIZE=10000
export PS_COLOR="0;32"
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1) /'
}

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

@emaillenin
emaillenin / Steps.txt
Created July 1, 2014 13:45
Working with a forked Github project
1. Fork the project
2. git clone <your-forked-repo>
3. Add a new remote of the original repo
4. Pull changes from original repo frequently and rebase against your local
5. Push changes to your repo
6. Create pull create and send it to the original repo!
@emaillenin
emaillenin / convertNumberToWordsForIndia9Digits.vb
Last active December 15, 2015 11:38
Converts a number (a currency) into words for Indian Format.. Supports upto 9 Digits.
Public Function convertNumberToWordsForIndia9Digits(ByVal number As Decimal)
'Based on this - http://www.php.net/manual/en/function.number-format.php#108532
'If you know the C# version, share it here http://blog.emaillenin.com
Dim words As New Hashtable
words.Add("0", "")
words.Add("1", "One")
words.Add("2", "Two")
words.Add("3", "Three")
words.Add("4", "Four")
words.Add("5", "Five")
@emaillenin
emaillenin / git-setup.sh
Created August 4, 2013 19:21
Creating a remote git repository
cd git-repo-dir
mkdir repo-name
cd repo-name
git init --bare
cd ..
chown -R gituser:gituser repo-name
/** In Git GUI, add a remote repo with URL as **/
@emaillenin
emaillenin / columns_accessed_recently.sql
Created December 12, 2013 13:47
Finds the columns that has been recently accessed in Teradata
select ObjectColumnName from dbc.dbqlobjtbl a
join dbc.dbqlogtbl b on a.ProcID = b.ProcID
and a.QueryID = b.QueryID
where ObjectDatabaseName = 'database_name' and ObjectTableName = 'table_name' and statementtype = 'Select' and ObjectType = 'Col'
@emaillenin
emaillenin / hyper.js
Created November 23, 2016 01:31
hyper.js
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 14,
// font family with optional fallbacks
fontFamily: 'Menlo, "DejaVu Sans Mono", "Lucida Console", monospace',
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
cursorColor: 'rgba(248,28,229,0.75)',
@emaillenin
emaillenin / HomeActivity.java
Created December 16, 2017 06:41
Branch Analytics and Referral Tracking for Custom APK files
@Override
public void onStart() {
super.onStart();
Branch branch = Branch.getInstance();
branch.initSession(new Branch.BranchReferralInitListener() {
@Override
public void onInitFinished(JSONObject referringParams, BranchError error) {
if (error == null) {
// params are the deep linked params associated with the link that the user clicked -> was re-directed to this app
@emaillenin
emaillenin / DownloadManagerActivity.java
Created December 11, 2016 04:54
Download APK using DownloadManager and start installation automatically - Android 7.0 Nougat compatible
public void downloadUpdate() {
DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE);
String destination = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS) + "/";
String fileName = "your_app.apk";
destination += fileName;
final Uri uri = Uri.parse("file://" + destination);
File file = new File(destination);
if (file.exists())
file.delete();