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
@trivektor
trivektor / states_hash.json
Last active January 5, 2017 20:11 — forked from mshafrir/states_hash.json
US states in JSON form
{
"AL": "Alabama",
"AK": "Alaska",
"AZ": "Arizona",
"AR": "Arkansas",
"CA": "California",
"CO": "Colorado",
"CT": "Connecticut",
"DE": "Delaware",
"FL": "Florida",
@trivektor
trivektor / gist:5d3e0e2050ef935c34a0d9faac54330d
Created July 18, 2016 21:23 — forked from iant/gist:ff76ec354907d8835cbc
Decoding rails cookies from rails console
# Run from 'rails console'
# Example cookie value. To find in Chrome: Inspect > Resources > Cookies
cookie = "cEJPOHAwUXdmMS9HK3gyVVYyNVR2QU03Q0ZhclZYNmRrN3RoelhrenQ3ZVhsSEtOTytQR29aZG1ZZWZmK254Y01QM2hyTVZMNlFOcWNCRytzM0pac0hpbFVWTUoxZEVicEZERXIzbEJENkJ4QVBZcDQyM24rclQxbnRFeXpkMVRicTdGMkVSU2F1U0FVcEdiYVBsRVFveThlMndPdDBlaThVVkl4TkFreUc0PS0tRFFmdlFzQnkrSmROT1ZNdnpjcnA4Zz09--3bf330ec809351525bd9df2c905a81a3bcc93c81"
# Example secret_key_base found in config/secrets.yml
secret_key_base = "df3def2698eb651febcb5ca64c3203a3cb3ff988e7ee5c4fd66135a24ddf5009ae0f95dee1e1d2e443538e647178f0cd87acc98d1082659bb03d89b8af1f2252"
key_generator = ActiveSupport::KeyGenerator.new(secret_key_base, iterations: 1000)
secret = key_generator.generate_key("encrypted cookie")
sign_secret = key_generator.generate_key("signed encrypted cookie")
encryptor = ActiveSupport::MessageEncryptor.new(secret, sign_secret, serializer: ActiveSupport::MessageEncryptor::NullSerializer)
puts encryptor.decrypt_and_verify(URI.unescape(cookie))
@trivektor
trivektor / deploy.rb
Created June 19, 2016 09:53 — forked from natew/deploy.rb
Puma + Nginx + Capistrano
require 'bundler/capistrano'
require 'capistrano_colors'
load 'deploy/assets'
# ssh forwarding and shell
set :default_run_options, { :pty => true }
set :ssh_options, { :forward_agent => true }
set :scm_verbose, true
set :scm, :git
@trivektor
trivektor / Alphasights_technical_challenge.md
Created May 4, 2016 16:16 — forked from tadast/Alphasights_technical_challenge.md
A technical challenge we give to our Ruby on Rails applicants in order to evaluate their coding proficiency. Job description: http://www.alphasights.com/positions/ruby-developer-london or http://www.alphasights.com/positions/ruby-developer-new-york

Alphasights Technical Challenge

Using Ruby on Rails we would like you to create a simple expert search tool. The application should fulfill the requirements below. The source code must be placed in a public repo on GitHub. The application should be deployable on Heroku.

  • I enter a name and a personal website address and a member is created.
  • When a member is created, all the heading (h1-h3) values are pulled in from the website to that members profile.
  • The website url is shortened (e.g. using http://goo.gl)
  • After the member has been added, I can define their friendships with other existing members. Friendships are bi-directional i.e. If David is a friend of Oliver, Oliver is always a friend of David as well.
  • The interface should list all members with their name, short url and the number of friends e.g. Alan http://goo.gl/3io1P (3)
@trivektor
trivektor / Enhance.js
Created April 26, 2016 05:10 — forked from sebmarkbage/Enhance.js
Higher-order Components
import { Component } from "React";
export var Enhance = ComposedComponent => class extends Component {
constructor() {
this.state = { data: null };
}
componentDidMount() {
this.setState({ data: 'Hello' });
}
render() {
@trivektor
trivektor / contactform.js
Created January 18, 2016 09:33 — forked from insin/contactform.js
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({

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

@trivektor
trivektor / criteria.txt
Created October 1, 2015 05:17 — forked from gigamonkey/criteria.txt
Hiring criteria: looking for the ability to …
Write a program that does what it’s supposed to do
Write idiomatic code
Debug a program that you wrote
Debug a program someone else wrote
Debug the interaction between a system you wrote and one you didn’t
File a good bug report
Modify a program you didn’t write
Test a program you wrote
Test a program you didn’t write
Learn a new programming language

Using Meld merging tool on Mac

  1. Install XQuartz

  2. Install meld with brew

     brew install meld
    
  3. Copy PYTHONPATH

# Change this:
...
#!/usr/bin/ruby
require 'osx/cocoa'
# My Script…