Skip to content

Instantly share code, notes, and snippets.

View akhilstanis's full-sized avatar

Akhil Stanislavose akhilstanis

View GitHub Profile
// Requires >= TS 4.1
type Put<Board, Player extends ('O' | 'X'), Position> = Board extends `
${infer P0} ${infer P1} ${infer P2}
${infer P3} ${infer P4} ${infer P5}
${infer P6} ${infer P7} ${infer P8}
` ? `
${Position extends P0 ? Player : P0} ${Position extends P1 ? Player : P1} ${Position extends P2 ? Player : P2}
${Position extends P3 ? Player : P3} ${Position extends P4 ? Player : P4} ${Position extends P5 ? Player : P5}
${Position extends P6 ? Player : P6} ${Position extends P7 ? Player : P7} ${Position extends P8 ? Player : P8}
@akhilstanis
akhilstanis / server.rb
Created December 5, 2019 15:16
SQL Injection Example
require 'sinatra'
require 'pg'
database_url = ENV['DATABASE_URL'] || 'postgres://localhost:5432/sql_injection'
pg = PG.connect(database_url)
pg.exec('CREATE TABLE IF NOT EXISTS users (username CHAR(50), password CHAR(50));')
set :session_secret, 'super_secret'
enable :sessions
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@akhilstanis
akhilstanis / titanic.csv
Created September 19, 2016 06:12
Titanic Data Set
passengerid survived pclass sex age sibsp parch fare embarked
1 0 3 male 22 1 0 7.25 S
2 1 1 female 38 1 0 71.2833 C
3 1 3 female 26 0 0 7.925 S
4 1 1 female 35 1 0 53.1 S
5 0 3 male 35 0 0 8.05 S
6 0 3 male -1 0 0 8.4583 Q
7 0 1 male 54 0 0 51.8625 S
8 0 3 male 2 3 1 21.075 S
9 1 3 female 27 0 2 11.1333 S
@akhilstanis
akhilstanis / gist:9113f015b5a6aec3c461
Last active December 15, 2015 06:34 — forked from davis-parakal/gist:6f155bc3982b48458a95
JD Sr. Backend Developer
• 2+ years of experience in developing highly scalable backend systems
• B.Tech / MCA / M.Tech / MSc Computer
• Experience in any of the following languages: Ruby, Python, Java, Node JS, GO, Groovy
• Skilled at writing clean, maintainable code - with the ability to come up with creative, efficient,and simple solutions.
• Previous experience developing REST APIs and integration solutions.
// Using Regexp for extracting title
var parseTitle = function(title) {
var parsed = title.match(/^\d+\.\s(.+)$/);
return ((parsed && parsed.pop()) || title);
};
var update = function(details) {
var id = details.id;
var index = details.index;
var title = parseTitle(details.title);
@akhilstanis
akhilstanis / gist:4983513
Created February 19, 2013 06:15
Snippet: Rails - Load Rails Enviornment (Used by daemons which requires rails env)
ENV['RAILS_ENV'] ||= "development"
require File.expand_path(File.dirname(__FILE__) + "/../../config/environment")
@akhilstanis
akhilstanis / Snippet: HAML - Bootstrap Flash Messages
Last active December 13, 2015 22:09
Snippet: HAML - Bootstrap Flash Messages
- flash.each do |name, msg|
- if msg.is_a?(String)
%div{:class => "alert alert-#{name == :notice ? "success" : "error"}"}
%a.close{"data-dismiss" => "alert"} ×
= content_tag :div, msg, :id => "flash_#{name}"
@akhilstanis
akhilstanis / gist:2069142
Created March 18, 2012 05:26
JS Libraries You should Use!
http://wavded.github.com/humane-js/ - Awesome notifications!
http://microjs.com/ - List of superb js libs.
http://imsky.github.com/cssFx/ - Adds vendor specific CSS3 prefixes.
http://ajkochanowicz.github.com/Kickstrap/index.html - Bootstrap with lots of addons
http://ivaynberg.github.com/select2/ - Super select box!