Skip to content

Instantly share code, notes, and snippets.

View ashishnegi's full-sized avatar

Ashish Negi ashishnegi

  • Software Developer
  • Austin, TX
View GitHub Profile
@ashishnegi
ashishnegi / init.el
Created October 22, 2014 13:54
Emacs where javascript works great :)
(setq inhibit-startup-message t)
(switch-to-buffer "*scratch*")
;(global-linum-mode)
(global-set-key (kbd "\C-x c") 'clipboard-kill-ring-save)
(global-set-key (kbd "\C-x p") 'clipboard-yank)
(setq make-backup-files t)
(setq version-control t)
(setq backup-directory-alist (quote ((".*" . "~/.emacs.d/.emacs_backups/"))))
@ashishnegi
ashishnegi / git-diff-clj.clj
Last active June 30, 2021 11:36
diff of two files in clojure
;;;;;;;;;;;; ---- diff.clj ------------------------
(ns diffclj.diff)
;; so what is diff
;; diff of two files
;; basic unit is line.
;; maximize the no of common lines.
;; longest-common-subseq.
(defn- make-pairs
@ashishnegi
ashishnegi / neural.clj
Last active August 29, 2015 14:19
Simple Logical gates : forward and backward pass in neuron function (x, y) = sigmoid(a*x + b*y + c)
;; a single unit has forward value and backward gradient.
(defrecord Unit
[value gradient])
(defrecord Gate
[^:Unit input-a ^:Unit input-b])
(defprotocol GateOps
(forward [this])
(backward [this back-grad]))
@ashishnegi
ashishnegi / cppfileparse.cpp
Last active August 29, 2015 14:19
Gets the function name and arguments : (problem with default values in function signature)
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <cctype>
#include <map>
namespace patch
{
@ashishnegi
ashishnegi / incidents-cluster-nearby.js
Created May 1, 2015 12:07
Cluster the reported incidents by their locations and category-id. *Not well tested.*
/*
* Fetch the data from public api.
* categorize the incidents in groups of
* {
category-id : [
for-each-category-a-list-of-list-of-incidents.
A-list-of-incidents : stores some nearby incidents.
]
}
@ashishnegi
ashishnegi / simpleparser1.hs
Created June 2, 2015 10:31
Simple parser from `Write Yourself a Scheme` in Haskell.
module Main where
import System.Environment
import Text.ParserCombinators.Parsec hiding (spaces)
import Control.Monad
import Numeric
import Data.Char (digitToInt, toLower)
-- our symbols are defined in here.
-- our word should start from one of these.
symbol :: Parser Char
@ashishnegi
ashishnegi / problem-quartz.clj
Created February 19, 2016 12:10
My problem with quartz.
Thanks for quartzite.
I am trying to make quartz work with jdbc store. However, i find that new jobs are not triggering.
I can see all new jobs and triggers in my database. My `defjobs` from another files also work.
It is just that jobs are not getting triggered.
My scheduler code is :
```clj
(ns theophrastus.utils
(:require [clojurewerkz.quartzite.scheduler :as qsched]
[clojurewerkz.quartzite.triggers :as qtrigger]
-- Sometimes we want to decode value of type a from a json list of a.. but each with some little differences..
-- Like server sends json: [{"name" : "a"},{"name" : "b"}]
-- and we have
type alias Player =
{ name : String
, color : Color
}
-- color is view specific and server is not sending it..
@ashishnegi
ashishnegi / chan_patterns.clj
Created April 18, 2017 08:59
principles and patterns of core async channels
(ns learn-clj.chan-patterns
(:require [clojure.core.async :as async]))
;; first create a channel..
(def mychan (async/chan))
;; # principles
;; #1 : taking/putting on a channel blocks if no one is putting/taking from it.
;; => can cause deadlocks if done synchronously.
;; so, do everything asynchronous or max 1 operation synchronous.
@ashishnegi
ashishnegi / dotnet_admin_mode.csv
Created October 30, 2017 13:28
Dotnet procmon logs when running as admin
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 2.
"Time of Day","Process Name","PID","Operation","Path","Result","Detail"
"1:24:35.1974924 PM","dotnet.exe","2380","Process Start","","SUCCESS","Parent PID: 2644, Command line: D:\Users\testadm\dotnet\dotnet.exe --version, Current directory: D:\Users\testadm\Downloads\SysinternalsSuite\, Environment:
; =::=::\
; =D:=D:\Users\testadm\Downloads\SysinternalsSuite
; =ExitCode=80008083
; ALLUSERSPROFILE=D:\ProgramData
; APPDATA=D:\Users\testadm\AppData\Roaming
; CLIENTNAME=ASNEGI-PC
; CommonProgramFiles=D:\Program Files\Common Files
; CommonProgramFiles(x86)=D:\Program Files (x86)\Common Files