Skip to content

Instantly share code, notes, and snippets.

const { Component } = React
const { Provider, connect } = ReactRedux
const { combineReducers } = Redux
const serverResponse = (size = 10) =>
Array.from({length: size}, () => Math.floor(Math.random() * size));
let mapStateToProps
//============================================================
const { Provider, connect } = ReactRedux
const appendItem = () => ({
type: 'APPEND_ITEM'
})
const initialState = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
const reducer = (state = initialState, action) => {
switch(action.type) {
@nihtalak
nihtalak / closure_context
Last active August 29, 2015 14:23
Context in closure
type Context struct {
db *sql.DB
}
func main() {
context := &Context{db}
router.GET("/", Handler(context))
}
func Handler(context *Context) httprouter.Handle {
@nihtalak
nihtalak / gist:54a43d72c6e132c2a333
Last active August 29, 2015 14:23
Injected context
struct Context {
db *sql.DB
}
struct AppHandler {
context *Context
hanlder func(response http.ResponseWriter, request *http.Request, _ httprouter.Params)
}
func (ah AppHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
@nihtalak
nihtalak / context_as_receiver
Last active August 29, 2015 14:23
Context as a receiver
type Context struct {
db *sql.DB
}
func InitContext() Context {
// init db
return Context{db}
}
func main() {
# Active Job
# Changed enqueueing method from +enqueue+ to +perform_later+
# beta1
MyJob.enqueue(*args)
# beta2
MyJob.perform_later(*args)
# Changed the way we schedule jobs
# beta1
@nihtalak
nihtalak / timezone_offset.js
Last active August 29, 2015 14:06
Timezone offset via JS
Date.prototype.stdTimezoneOffset = function() {
var jan = new Date(this.getFullYear(), 0, 1),
jul = new Date(this.getFullYear(), 6, 1);
return Math.max(jan.getTimezoneOffset(), jul.getTimezoneOffset());
};
new Date().stdTimezoneOffset(); // -120
@nihtalak
nihtalak / drop_using_db.sql
Created August 4, 2014 13:54
Drop database in use
drop schema public cascade;
create schema public;
{
"events": {
"template" : "events*",
"settings" : {
},
"mappings" : {
"widget" : {
"properties" : {
"application_id" : {
"type" : "string",

Note that this validation runs both after the file is uploaded and after CarrierWave has processed the image. If your base uploader includes a filter to resize the image then the validation will be run against the resized image, not the original one that was uploaded. If this causes a problem for you, then you should avoid using a resizing filter on the base uploader and put any specific size requirements in a version instead.

So instead of this:

require 'carrierwave/processing/mini_magick'