Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻

Nadeem Bitar shinzui

👨‍💻
  • Los Angeles / San Francisco
  • Twitter @shinzui
View GitHub Profile
@shinzui
shinzui / datasize.rake
Created Feb 14, 2010
Rake task to get database and table sizes.
View datasize.rake
# Run rake db:size to get a print of your database size in bytes.
# Run rake db:tables:size to get the sizes for individual tables
# Works for MySQL and PostgreSQL. Not tested elsewhere.
namespace :db do
desc 'Print data size for entire database'
task :size => :environment do
database_name = ActiveRecord::Base.connection.instance_variable_get("@config")[:database]
adapter = ActiveRecord::Base.connection.adapter_name.downcase
@shinzui
shinzui / tmux.conf
Created Mar 12, 2011 — forked from bryanl/tmux.conf
tmux.conf
View tmux.conf
# ~/.tmux.conf
#
# See the following files:
#
# /opt/local/share/doc/tmux/t-williams.conf
# /opt/local/share/doc/tmux/screen-keys.conf
# /opt/local/share/doc/tmux/vim-keys.conf
#
# URLs to read:
#
View Fast user switching with Devise
Ever wondered how to login as another user within Devise?
Recently we had a feature request that would provide Admins with the ability
to sign is as another user. You could imagine live demonstrations or even production
support calls where you would like to be signed in as another user, yet not
have to ask for or decrypt their current password. After stewing for a bit, we found a
pretty nice solution with Devise.
Here's the Cucumber feature...
@shinzui
shinzui / haskell-records.md
Created Apr 8, 2021 — forked from mtesseract/haskell-records.md
Working around Haskell's namespace problem for records
View haskell-records.md

The Problem

Defining records in Haskell causes accessor functions for the record's fields to be defined. There is no seperate namespace for these accessor functions.

The Goal

Be able to

  • use records in Haskell, which share field names.
  • use lenses for accessing these fields
View Optics Cheatsheet.md
@shinzui
shinzui / Pubsub.hs
Created Dec 4, 2020 — forked from jamesthompson/Pubsub.hs
Example pub/sub grpc interface with fused-effects
View Pubsub.hs
{-# LANGUAGE AllowAmbiguousTypes #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE KindSignatures #-}
@shinzui
shinzui / rack-notags.rb
Created Aug 29, 2010 — forked from janlelis/rack-notags.rb
Rack middleware to clean post and get params
View rack-notags.rb
# # # #
# Rack::NoTags removes < and > from all incoming requests
# http://rbjl.net/12-rack-notags
#
# (c) 2009 - 2010 Jan Lelis
# This software is licensed under the MIT license.
# # # #
module Rack
@shinzui
shinzui / Environment.hs
Created May 25, 2020 — forked from clementd-fretlink/Environment.hs
Env var parsing with free applicatives
View Environment.hs
#!/usr/bin/env stack
-- stack --resolver lts-14.20 --install-ghc runghc --package either --package free
{-# LANGUAGE DeriveFunctor #-}
module Main
where
import Control.Applicative.Free
import Data.Bifunctor (first)
import Data.Either.Combinators (maybeToRight)
import Data.Either.Validation
View Perf writeup.md

Modern applications

Most JavaScript developers love making modern applications, with our new language features and latest libraries making our life easier, but has any one ever actually wondered if this ever impacts our users.

We are dealing with abstractions, abstractions are trying to cover a general use case which could not be conforming to yours. Some are over-engineered in ways one can't possibly comprehend, use cases that will never be reached by middle sized applications. Some of these over