Skip to content

Instantly share code, notes, and snippets.

View AnkurGel's full-sized avatar
:octocat:
Awesomeness

Ankur Goel AnkurGel

:octocat:
Awesomeness
View GitHub Profile
@AnkurGel
AnkurGel / gist.js
Last active June 9, 2018 21:02
working gist
function messageServer() {
const xhr = new XMLHttpRequest();
const url = 'https://api.nytimes.com/svc/search/v2/articlesearch.json?api-key=eaf6455bd8eb4f11a1f08923b811081e&q=this&begin_date=won%27t&end_date=work'
xhr.onreadystatechange = () => {
console.log("Ready state: " + xhr.readyState + ", response: " + xhr.response);
if(xhr.readyState === XMLHttpRequest.DONE) {
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CommandUUID</key>
<string>0414ddf8-e49a-4cc9-ac4f-d2f9c012c364</string>
<key>ProfileList</key>
<array>
<dict>
<key>HasRemovalPasscode</key>
if ENV['ENABLE_REMOTE_DEBUGGER_UNDER_POW'] && Debugger
Debugger.settings[:autoeval] = true
Debugger.settings[:autolist] = 1
Debugger.settings[:reload_source_on_change] = true
Debugger.start_remote
end
# in .powenv - export ENABLE_REMOTE_DEBUGGER_UNDER_POW=true
@AnkurGel
AnkurGel / gist:8376486
Created January 11, 2014 20:45
http://regex.alf.nu/ Answers Regex Golf
  1. Plain Strings : foot* - Self explanatory
  2. Anchors : k$ - Ends with letter 'k'
  3. Ranges : ^[a-f]*$ - All alphabets are in range a-f
  4. Backrefs : (...).*\1 - 4 alphabets are repeated somewhere later in string
  5. abba : ^(?!.*(.)(.)\2\1) - 2 alphabets followed by reverse, capture backreference and play them in reverse. Answer is those strings which do not match this pattern, we do that by negative lookahead assertion
  6. A man, a plan : ^(.)(.).*\2\1$ - Similar to above
  7. Prime : `` - TODO
  8. Four : (.).\1.\1.\1 - a letter is repeated 4 times in string somewhere; capture backreference and play it over
  9. Order : ^[^o].....?$ or ^[^o].{4,5}$ - string has 5-6 letters; one string which starts with 'o' protests, so add negation for that and subtract one from range. Simple
  10. Triples : `` - TODO
@AnkurGel
AnkurGel / gist:8208584
Created January 1, 2014 14:51
readline package failed
autoheader: warning: missing template: CTYPE_NON_ASCII
autoheader: Use AC_DEFINE([CTYPE_NON_ASCII], [], [Description])
autoheader: warning: missing template: FIONREAD_IN_SYS_IOCTL
autoheader: warning: missing template: HAVE_BSD_SIGNALS
autoheader: warning: missing template: HAVE_GETPW_DECLS
autoheader: warning: missing template: HAVE_LANGINFO_CODESET
autoheader: warning: missing template: HAVE_MBRLEN
autoheader: warning: missing template: HAVE_MBSRTOWCS
autoheader: warning: missing template: HAVE_MBSTATE_T
autoheader: warning: missing template: HAVE_POSIX_SIGNALS
@AnkurGel
AnkurGel / gist:7503379
Created November 16, 2013 18:07
tmux conf
set -g prefix C-x
unbind %
bind | split-window -h
bind - split-window -v
@AnkurGel
AnkurGel / unique_files.rb
Created October 11, 2013 01:26
Script for pratik
all_files = Dir['*']
order = all_files.group_by{ |x| File.size(x) }.values
similar_files = order.select { |x| x.size > 1 }
pick_files = similar_files.map{ |x| x[0] }
similar_files.each do |x|
x.each do |file|
#to use FileUtils.compare_file here
File.delete(file) unless pick_files.include?(file)
end
end
@AnkurGel
AnkurGel / leading.rb
Last active December 25, 2015 05:59
Leading Trailing
class Production
attr_reader :left, :right, :raw
def initialize(input_string)
@raw = input_string.chomp.to_s
raise ArgumentError,
"Should be valid production (eg: E -> E + id)" unless @raw.match(/-\>/)
@left, @right = @raw.split('->').map(&:strip)
end
def non_terminals
@AnkurGel
AnkurGel / kf.rb
Created September 13, 2013 23:01
KF
[7] pry(main)> require 'bio-statsample-timeseries'
=> true
[8] pry(main)> ts = (1..100).to_a.to_ts
=> Time Series(type:scale, n:100)[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100]
[9] pry(main)> include Statsample::TimeSeries::Arima
=> Object
[10] pry(main)> KalmanFilter.ks(ts, 3, 1)
[ 0.000e+00 0.000e+00 0.000e+00 0.000e+00 ]
ll = 457.3719102223828
[ 1.000e-01 0.000e+00 0.000e+00 0.000e+00 ]