Skip to content

Instantly share code, notes, and snippets.

View mshirdel's full-sized avatar
🏠
Working from home

Meysam Shirdel mshirdel

🏠
Working from home
View GitHub Profile
SharedPreferences settings;
settings = getSharedPreferences("PREF_NAME", Context.MODE_PRIVATE);
//get the sharepref
int id = settings.getInt("ID", 0);
//set the sharedpref
Editor editor = settings.edit();
editor.putInt("ID", "1");
editor.commit();
@mshirdel
mshirdel / List All
Last active August 29, 2015 14:20
List all files
find . -type f -exec echo {} \;
@mshirdel
mshirdel / Find Duplicate
Created May 9, 2015 09:08
Find duplicate files in bash
find . -type f -exec echo \"{}\" \;> files.list
cat files.list | xargs md5sum > files-hash.list
sort files-hash.list | uniq -d --check-char=32 > result.list
@mshirdel
mshirdel / FontRegEx
Last active August 29, 2015 14:21 — forked from siwells/gist:1114395
RegEx for replacing font tag
/*
* Clear the highlighting to allow the user to toggle
* between the original page & the highlighted page.
*/
function clearHighlighting()
{
alert("clearing hightlighting...");
if (!document.body || typeof(document.body.innerHTML) == "undefined") {
if (warnOnFailure) {
@mshirdel
mshirdel / host_url
Created June 17, 2015 10:58
URL and host
var url = location.protocol.concat("//") + window.location.host;
# How to find out where a method comes from.
# Learned this from Dave Thomas while teaching Advanced Ruby Studio
# Makes the case for separating method definitions into
# modules, especially when enhancing built-in classes.
module Perpetrator
def crime
end
end
class Fixnum
@mshirdel
mshirdel / kill_process
Last active April 27, 2016 10:19
Find and kill a process in one line using bash and regex
kill $(ps aux | grep '[p]ython csp_build.py' | awk '{print $2}')
@mshirdel
mshirdel / SetSqlServerCompatibility
Last active June 19, 2016 08:42
Set SQL Server compatibility level
alter database Pishgaman_CRM set compatibility_level = 110
select compatibility_level from sys.databases where name = 'Pishgaman_CRM'
#!/bin/bash
# this script is not written by me. Just using it and sharing it here.
# export DBUS_SESSION_BUS_ADDRESS environment variable useful when the script is set as a cron job
PID=$(pgrep gnome-session)
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)
# $bing is needed to form the fully qualified URL for
To delete a local branch
git branch -d the_local_branch
To remove a remote branch (if you know what you are doing!)
git push origin :the_remote_branch