Skip to content

Instantly share code, notes, and snippets.

View Jaskirat's full-sized avatar

Jaskirat Jaskirat

View GitHub Profile
@Jaskirat
Jaskirat / commandline.sh
Created March 19, 2012 10:29
Pyp/Awk/Sed at al
#PYP
ls -l | pyp "pp[5:11:2] | whitespace[2], w[-1] | p.replace('hello','goodbye') | p.title(),'is splendid'"
#AWK/SED
ls -l | awk 'NR>=5 && NR<11 {print $3,$9}' | sed 'n;d' | sed -e 's/hello/goodbye/g' -re 's/(^| )([a-z])/\1\u\2/g' -e 's/$/ is splendid/'
#Also using Record stream
ls -l |awk 'NR>=5 && NR<11' | sed 'n;d'|sed -r 's/\s+/,/g'| sed 's/hello/goodbye/g' | recs-fromcsv | recs-eval 'ucfirst({{2}})." ".ucfirst({{8}})." is splendid"'
@Jaskirat
Jaskirat / insertion-sort.clj
Created March 10, 2012 20:54
Insertion sort in clojure
(defn insert [l k]
"Function to do insert in sorted order"
(concat (filter #(< % k) l) [k] (filter #(> % k) l)))
(defn isort [l]
"Insertion sort"
(loop [r []
l l]
(if (empty? l)
r
;; jaskirat's solution to The Big Divide
;; https://4clojure.com/problem/148
(fn [n a b]
(let [e #(quot (- n 1) %)
f #(* % (/ (* (e %) (inc (e %))) 2))
x (f a)
y (f b)
z (f (* a b))]
(- (+ x y) z)))
$.editable.addInputType( 'datepicker', {
/* create input element */
element: function( settings, original ) {
var form = $( this ),
input = $( '<input />' );
input.attr( 'autocomplete','off' );
form.append( input );
form.append('<input id=jedate_ type=hidden value=false>')
return input;
>>> ping hsejiv.blogspot.com
Pinging blogspot.l.google.com [209.85.153.132] with 32 bytes of data:
Request timed out.
Ping statistics for 209.85.153.132:
Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),
>> tracert 209.85.153.132
@Jaskirat
Jaskirat / swank-clojure.bat
Created February 11, 2011 21:04
swank-clojure.bat
@echo off
rem This script was automatically generated by Leiningen.
setLocal
if "x%JVM_OPTS%" == "x" set JVM_OPTS=%JAVA_OPTS%
set CLASSPATH="%USERPROFILE%\.m2\repository\swank-clojure\swank-clojure\1.3.0-SNAPSHOT\swank-clojure-1.3.0-SNAPSHOT.jar;%USERPROFILE%\.m2\repository\org\clojure\clojure\1.2.0\clojure-1.2.0.jar"
set VERSION="swank.swank"
@Jaskirat
Jaskirat / OutlookMacro.vb
Created January 4, 2010 06:38
MS Outlook forgotten attachment reminder
Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim m As Variant
Dim strBody As String
Dim intIn As Long
Dim intAttachCount As Integer, intStandardAttachCount As Integer
On Error GoTo handleError
'Edit the following line if you have a signature on your email that includes images or other files. Make intStandardAttachCount equal the number of files in your signature.