Skip to content

Instantly share code, notes, and snippets.

@sarim
sarim / README.md
Last active February 5, 2020 20:01
Gittu Smart Path Prompt for Bash

##What is it ? Many of us like to see pwd in bash prompt. However if we travel too deep inside directory trees, the path becomes very lengthy and almost eats all the space. So its good to only show last part of the path. That what this script does.

Before:

Before

After:

After

@sarim
sarim / repairsqlite.sh
Created September 6, 2013 08:14
Sqlite db repair script
#!/bin/bash
DBSTATUS=$(sqlite3 "$1" "PRAGMA integrity_check")
if [ "$DBSTATUS" == "ok" ] ; then
echo DB ALREADY OK
else
echo FIXING CORRUPT DB
TMPDB=$(mktemp -t sarim)
echo ".mode insert
.dump" | sqlite3 "$1" > $TMPDB
@sarim
sarim / telnet
Created October 14, 2013 14:53
Stackoverflow is unreachable from Teletalk 3G.
$ telnet 198.252.206.16 80
Trying 198.252.206.16...
Connected to stackoverflow.com.
Escape character is '^]'.
GET / HTTP/420.0
HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=us-ascii
Date: Mon, 14 Oct 2013 14:50:56 GMT
Connection: close
diff --git a/avropref.ui b/avropref.ui
index 0c111c0..95bb17f 100644
--- a/avropref.ui
+++ b/avropref.ui
@@ -3,7 +3,7 @@
<!-- interface-requires gtk+ 3.0 -->
<object class="GtkAdjustment" id="lutable_size">
<property name="lower">5</property>
- <property name="upper">16</property>
+ <property name="upper">15</property>
@sarim
sarim / gholder.js
Created November 4, 2013 08:40
experiment svg holderjs
GHolder = {
basesvg :
'<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="%width%" height="%height%">' +
' <rect width="100%" height="100%" style="fill:%backcolor%;" />' +
' <text x="0" y="50%" fill="%forecolor%" textLength="100%" style="font-size: 48px">%text%</text>' +
'</svg>' ,
run : function() {
var imgs = document.querySelectorAll("img");
for (i=0;i<imgs.length;++i){
if ( (imgs[i].getAttribute("src") || '').search("gholder.js/") === 0 || (imgs[i].getAttribute("data-src") || '').search("gholder.js/") === 0 ){
@sarim
sarim / dabblet.css
Created November 26, 2013 21:43
iOS 6 style switch checkboxes
/**
* iOS 6 style switch checkboxes
* by Lea Verou http://lea.verou.me
*/
:root input[type="checkbox"] { /* :root here acting as a filter for older browsers */
position: absolute;
opacity: 0;
}
import re
gamelog = "./games.log"
scoredb = {}
def addscore(killer):
if killer not in scoredb:
if re.search('_\d+$',killer):
originalkiller = re.search('(.*)_\d+$',killer).groups()[0]
addscore(originalkiller)
else:
@sarim
sarim / -
Created December 15, 2013 18:57
[Desktop Entry]
Version=1.0
Name=Sublime Text 2
# Only KDE 4 seems to use GenericName, so we reuse the KDE strings.
# From Ubuntu's language-pack-kde-XX-base packages, version 9.04-20090413.
GenericName=Text Editor
Exec=sublime
Terminal=false
Icon=/opt/Sublime Text 2/Icon/48x48/sublime_text.png
@sarim
sarim / -
Created December 19, 2013 20:16
//Code to keep div fixed at top during scrolling. heavily inspired from http://goo.gl/zYykrQ
var scroller = {
touchstart: function(e) {
e.data.state.posY = e.touches[0].clientY;
e.data.state.offsetY = $('#indicator').offset().top;
$("#status").html("touchstart");
},
touchmove: function(e) {
var currentY = e.touches[0].clientY;
var deltaY = currentY - e.data.state.posY;
@sarim
sarim / Castle.xml
Created January 6, 2014 13:44 — forked from kwmt/Castle.xml
<?xml version="1.0" encoding="UTF-8" ?>
<Data>
<Series>
<id>83462</id>
<Actors>|Nathan Fillion|Stana Katic|Molly C. Quinn|Jon Huertas|Seamus Dever|Tamala Jones|Susan Sullivan|Ruben Santiago-Hudson|Monet Mazur|</Actors>
<Airs_DayOfWeek>Monday</Airs_DayOfWeek>
<Airs_Time>10:00 PM</Airs_Time>
<ContentRating>TV-PG</ContentRating>
<FirstAired>2009-03-09</FirstAired>
<Genre>|Drama|</Genre>