Skip to content

Instantly share code, notes, and snippets.

View ashokgelal's full-sized avatar
🌐
Building

Ashok Gelal ashokgelal

🌐
Building
View GitHub Profile
@ashokgelal
ashokgelal / header_appender.py
Created February 16, 2011 03:54
Prepends a heading read from header.txt to all .cs files
""" This script prepends a heading (read from header.txt) to all .cs files.
It searches for all the .cs files including *.designer.cs recursively
starting at the location of this script.
This script accepts two command line arguments:
-l, --list : lists all files that are going to be processed
-a, --append : Appends the contents of header.txt to each *.cs files
"""
# Author: Ashok Gelal
# Version: 0.0.1
# And just for historical reason - this is my first Python script
@ashokgelal
ashokgelal / AppDelegate.cs
Created February 19, 2011 07:03
ApplicationShouldTerminateAfterLastWindowClosed
public override bool ApplicationShouldTerminateAfterLastWindowClosed (NSApplication sender)
{
return true;
}
@ashokgelal
ashokgelal / chdir.c
Created September 19, 2011 06:29
chdir implementation
void changeDir(char *path){
if(path == '\0'){
// get home path
uid_t id = getuid();
struct passwd *pwd = getpwuid(id);
path = (pwd == NULL ? ) "." : pwd->pw_dir;
}
int status = chdir(path);
if(status == 0){
@ashokgelal
ashokgelal / bash terminal title
Created November 6, 2011 18:15
bash script to automatically set the title of terminal's window + tabs to current path
settitle ()
{
echo -ne "\033]0;${PWD/$HOME/~}\007"
}
PROMPT_COMMAND=settitle
export PROMPT_COMMAND
@ashokgelal
ashokgelal / CoverFlow.cs
Created February 27, 2012 00:46 — forked from conceptdev/CoverFlow.cs
MonoDroid port of a CoverFlow-showing Activity for Android http://twitpic.com/46n72l
/*
* ORIGINAL (JAVA) CODE LICENCE
*
* Copyright (C) 2010 Neil Davies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0

Installation

Clone this Gist, copy in dropbox-android-sdk.jar file from Dropbox SDK. Change version in POMs if you need it, then run mvn clean install.

Usage

<dependency>
  <artifactId>android-sdk</artifactId>
 1.5
@ashokgelal
ashokgelal / MEFExtensions.cs
Created December 10, 2014 17:00
MEF Exception Unwrapper
/// <summary>
/// Attempts to retrieve the real cause of a composition failure.
/// </summary>
/// <remarks>
/// Sometimes a MEF composition fails because an exception occurs in the ctor of a type we're trying to
/// create. Unfortunately, the CompositionException doesn't make that easily available, so we don't get
/// that info in haystack. This method tries to find that exception as that's really the only one we care
/// about if it exists. If it can't find it, it returns the original composition exception.
/// </remarks>
/// <param name="exception"></param>
import Foundation
extension String
{
var length: Int {
get {
return countElements(self)
}
}
@ashokgelal
ashokgelal / gist:fa85a4b94b22319020bcbaba0b0278df
Created May 4, 2016 01:42
Hacking router - wlctl usage help
Usage: wlctl [-a|i <adapter>] [-h] [-d|u|x] <command> [arguments]
-h this message and command descriptions
-h [cmd] command description for cmd
-a, -i adapter name or number
-d output format signed integer
-u output format unsigned integer
-x output format hexdecimal
ver get version information
@ashokgelal
ashokgelal / LinkMonitor.php
Created March 12, 2017 00:39
Extend Monitor to add a raw_url attribute
class LinkMonitor extends Monitor
{
protected $table = 'monitors';
protected $appends = ['raw_url'];
/**
* @return string
*/
public function getRawUrlAttribute()