Skip to content

Instantly share code, notes, and snippets.

View coreyjs's full-sized avatar

Corey Schaf coreyjs

View GitHub Profile
@muxcmux
muxcmux / version.rake
Created February 12, 2012 02:53
Manage your rails app version with this rake task
def valid? version
pattern = /^\d+\.\d+\.\d+(\-(dev|beta|rc\d+))?$/
raise "Tried to set invalid version: #{version}".red unless version =~ pattern
end
def correct_version version
ver, flag = version.split '-'
v = ver.split '.'
(0..2).each do |n|
v[n] = v[n].to_i
@jboner
jboner / latency.txt
Last active June 29, 2024 19:54
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@nikcub
nikcub / README.md
Created October 4, 2012 13:06
Facebook PHP Source Code from August 2007
@mtowers
mtowers / README.md
Last active February 24, 2022 17:19
Google Analytics Website Visitor Count Widget for Dashing with OAuth2 Authentication
@davidbella
davidbella / person.rb
Created October 10, 2013 13:37
Ruby: Dynamic meta-programming to create attr_accessor like methods on the fly
class Person
def initialize(attributes)
attributes.each do |attribute_name, attribute_value|
##### Method one #####
# Works just great, but uses something scary like eval
# self.class.class_eval {attr_accessor attribute_name}
# self.instance_variable_set("@#{attribute_name}", attribute_value)
##### Method two #####
# Manually creates methods for both getter and setter and then
# MODEL
class Case < ActiveRecord::Base
include Eventable
has_many :tasks
concerning :Assignment do
def assign_to(new_owner:, details:)
transaction do
@sykire
sykire / per_inline_model_converter.py
Last active April 9, 2021 07:16
Usually in flask-admin inline-models use the same converter. You can set a different converter setting 'inline_converter' in the ModelView but this will apply the same converter for every Model in the inline_models list.So I've overridden the 'scaffold_inline_form_models' method from ModelView just to check for every inline model in the list if …
from flask_admin.form import FormOpts
from flask_admin.contrib.sqla.form import InlineModelFormList, \
InlineModelConverter, \
get_form
from flask_admin.contrib.sqla.tools import get_primary_key
from flask_admin.contrib.sqla import ModelView
from flask_admin.model.fields import InlineModelFormField
from flask_admin.model.form import InlineFormAdmin
from flask_admin._compat import iteritems
@BenTristem
BenTristem / AudioTrigger.cs
Created April 23, 2017 16:41
Simple audio trigger with layer filter.
using UnityEngine;
public class AudioTrigger : MonoBehaviour
{
[SerializeField] AudioClip clip;
[SerializeField] int layerFilter = 0;
[SerializeField] float triggerRadius = 5f;
[SerializeField] bool isOneTimeOnly = true;
[SerializeField] bool hasPlayed = false;
@480
480 / gist:3b41f449686a089f34edb45d00672f28
Last active June 27, 2024 06:21
MacOS X + oh my zsh + powerline fonts + visual studio code terminal settings

MacOS X + oh my zsh + powerline fonts + visual studio code (vscode) terminal settings

Thank you everybody, Your comments makes it better

Install oh my zsh

http://ohmyz.sh/

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
@trentpolack
trentpolack / EnumerationType.h
Last active June 7, 2021 18:30
Enumerations in Unreal Engine 4
// Generally, developers in UE4 tend towards the following convention for enumerations:
UENUM( BlueprintType )
enum class ENoiseGeneratorCellularType : uint8
{
NGCT_Natural UMETA( DisplayName = "Natural" ),
NGCT_Euclidean UMETA( DisplayName = "Euclidean" ),
NGCT_Manhattan UMETA( DisplayName = "Manhattan" ),
NGCT_Max UMETA( Hidden )
};