Skip to content

Instantly share code, notes, and snippets.

View trivektor's full-sized avatar
🏠
Working from home

Tri Vuong trivektor

🏠
Working from home
View GitHub Profile
@jirutka
jirutka / example_non_styled.yml
Last active August 31, 2021 16:40 — forked from mislav/example.rb
A Psych extension to enable choosing output styles for specific objects.
# default boring output of Psych.dump
---
:response:
:body: ! "{\n \"page\": 1,\n \"results\": [\n \"item\", \"another\"\n ],\n
\ \"total_pages\": 0\n}\n"
:status: 200
:person:
name: Steve
age: 24
:array:
@kartikkukreja
kartikkukreja / Maximum Subarray Problem.py
Last active August 29, 2015 14:04
Maximum Subarray Problem
let A be the given array of integers
let maxSum = -infinity, maxLeft = 0, maxRight = 0, currentMax = 0, left = 0, right = 0
for i = 0 to A.length - 1
currentMax += A[i]
if currentMax > maxSum
maxSum = currentMax
right = i;
maxLeft = left
maxRight = right
if currentMax < 0
@hkhamm
hkhamm / installing_cassandra.md
Last active May 5, 2024 13:14
Installing Cassandra on Mac OS X

Installing Cassandra on Mac OS X

Install Homebrew

Homebrew is a great little package manager for OS X. If you haven't already, installing it is pretty easy:

ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
@smsohan
smsohan / rename_angular_parts
Last active April 28, 2016 15:55
AngularJS renaming exercise
Because I think the hardest part of getting started with AngularJS is it's esoteric names, I'm suggesting the following replacements of the AngularJS terminology.
scope -> state
factory -> data/models
filter -> helper
directive {restrict: 'E'} -> custom_tag
directive {restrict: 'A'} -> custom_attribute
@nielsvanderbeke
nielsvanderbeke / slow_http_attacks.md
Created February 14, 2014 08:04
Slow HTTP Attacks

Slow HTTP attacks are denial-of-service (DoS) attacks in which the attacker sends HTTP requests in pieces slowly, one at a time to a Web server. If an HTTP request is not complete, or if the transfer rate is very low, the server keeps its resources busy waiting for the rest of the data. When the server’s concurrent connection pool reaches its maximum, this creates a DoS. Slow HTTP attacks are easy to execute because they require only minimal resources from the attacker.

Attack exploits the fact that most of modern web servers are not limiting the connection duration if there is a data flow going on, and with possiblity to prolong TCP connection virtually forever with zero or minimal data flow by manipulating TCP receive window size value, it is possible to acquire concurent connections pool of the application. Possibility to prolong TCP connection is described in several vulnerability reports: MS09-048, CVE-2008-4609, CVE-2009-1925, CVE-2009-1926 .

Prerequisites for the successful attack are: - victim serve

@insin
insin / contactform.js
Last active January 9, 2024 05:27
React contact form example
/** @jsx React.DOM */
var STATES = [
'AL', 'AK', 'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', 'GA', 'HI',
'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA', 'MI', 'MN', 'MS',
'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR',
'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY'
]
var Example = React.createClass({
@commadelimited
commadelimited / readme.txt
Created October 1, 2013 14:55
Nested URLs
I'm trying to consume an endpoint from my server to retrieve interactions.
This interaction is restricted by account and can only be accessed once you're within the account route.
URLs
----
/activity/#/accounts/64/ <-- loads account information
/activity/#/accounts/64/interactions <-- I want to load interactions here
Ember is making a call to the interactions endpoint, but it's hitting the wrong path:
@aprato
aprato / AMPNavigationBar.m
Last active July 13, 2018 00:23
Darker iOS7 translucent UINavigationBar
// .h
@interface AMPNavigationBar : UINavigationBar
@property (nonatomic, assign) CGFloat extraColorLayerOpacity UI_APPEARANCE_SELECTOR;
@end
// .m
@patrickleet
patrickleet / gist:6312627
Created August 22, 2013 20:51
meteor.js cheatsheet
// Assuming the following directory structure
/*
app/
.meteor/
client/
server/
collections/
*/
// 1. Create a collection
@adityamukho
adityamukho / User.js
Last active November 11, 2021 21:41
Passport authentication for Sails.js 0.9.x
/**
* api/models/User.js
*
* The user model contains the instance method for validating the password.
*/
var bcrypt = require('bcrypt');
function hashPassword(values, next) {
bcrypt.hash(values.password, 10, function(err, hash) {