Skip to content

Instantly share code, notes, and snippets.

@c80609a
c80609a / integer.rb
Created November 8, 2016 11:38 — forked from pithyless/integer.rb
Ruby Integer::MAX and Integer::MIN
class Integer
N_BYTES = [42].pack('i').size
N_BITS = N_BYTES * 16
MAX = 2 ** (N_BITS - 2) - 1
MIN = -MAX - 1
end
p Integer::MAX #=> 4611686018427387903
p Integer::MAX.class #=> Fixnum
p (Integer::MAX + 1).class #=> Bignum
@c80609a
c80609a / Input.js
Created March 1, 2017 08:28 — forked from grifdail/Input.js
The best javascript input controller for game. Include gamepad support.
/*
Input.jump = {
key: 32//Space
gamepad: 0// A button on as XBOX360 gamepad
}
dont forget to call
Input.update();
at the end of each frame.
# Rails Engine call
`rails plugin new MY_ENGINE --dummy-path=spec/dummy --skip-test-unit --full --database=mysql`
or `rails plugin new ENGINE_NAME --dummy-path=spec/dummy --skip-test-unit --mountable --database=mysql`
# Configure spec_helper.rb
ENV["RAILS_ENV"] = "test"
require File.expand_path("../dummy/config/environment.rb", __FILE__)
require 'rspec/rails'
@c80609a
c80609a / redis-setbit-test.coffee
Created August 18, 2017 14:15 — forked from saadullahsaeed/redis-setbit-test.coffee
Testing 'setbit' and 'bitcount' on Redis 2.6
express = require 'express'
redis = require 'redis'
app = express()
requestCount = 0
client = null
#Going to use Date as the Key
getKey= ->
d = new Date()
# 100mil 'entities'
# need to be able to check from a random subset if 'something' is TRUE or FALSE
# set booleans in a redis bitmap where the ID for the entities are the offset
$ redis-cli
> SETBIT mybitmap 100000000 1 # 8ms
> SETBIT mybitmap 99999999 1 # 2ms
> SETBIT mybitmap 10000000 1 # 2ms, etc
@c80609a
c80609a / am_dry_validation_1.rb
Created December 11, 2018 14:51 — forked from solnic/am_dry_validation_1.rb
dry-validation vs activemodel
require 'benchmark/ips'
require 'active_model'
require 'virtus'
require 'dry-validation'
require 'dry/validation/schema/form'
class User
include ActiveModel::Validations
include Virtus.model
@c80609a
c80609a / redux-is-smarter-than-you-think.md
Created December 13, 2018 12:37 — forked from armw4/redux-is-smarter-than-you-think.md
Optimizing your react components via redux....shouldComponentUpdate for free and more...

The Beginning

Yes...it's true...redux is smart....smarter than you even know. It really does want to help you. It strives to be sane and easy to reason about. With that being said, redux gives you optimizations for free that you probably were completely unaware of.

connect()

connect is the most important thing in redux land IMO. This is where you tie the not between redux and your underlying components. You usually take state and propogate it down your component hiearchy in the form of props. From there, presentational

@c80609a
c80609a / inspetor_teste_front_end.md
Created April 18, 2019 13:22 — forked from phsanzovo/inspetor_teste_front_end.md
Teste Prático de Desenvolvimento Front-End Inspetor

Teste Prático de Desenvolvimento Front-End Inspetor

Estruturar e Integrar

Utilizando a API TVMaze, você deverá estruturar uma aplicação para basicamente 2 funcionalidades:

  • Exibir uma lista de Séries de TV;
  • Detalhar uma Série selecionada;

Documentação da API: http://www.tvmaze.com/api

1. Fonte da Informação

@c80609a
c80609a / addCron.md
Created April 18, 2019 13:24 — forked from marcostolosa/addCron.md
Create a Cron Job Using Bash (Shell Script) Automatically Without Interactive Editor

Adding a Cron Job via Shell Script

#write out current crontab
crontab -l > mycron

#echo new cron into cron file
echo "00 09 * * 1-5 echo hello" >> mycron

#install new cron file
@c80609a
c80609a / gist:0bed07fe2de6f26e28b596f71acfe7dd
Created May 12, 2019 15:23 — forked from yesvods/gist:51af798dd1e7058625f4
Merge Arrays in one with ES6 Array spread
const arr1 = [1,2,3]
const arr2 = [4,5,6]
const arr3 = [...arr1, ...arr2] //arr3 ==> [1,2,3,4,5,6]