Skip to content

Instantly share code, notes, and snippets.

View keichan34's full-sized avatar
👋
Hello!

Keitaroh Kobayashi keichan34

👋
Hello!
View GitHub Profile
@einkoro
einkoro / hhvm_setcookie_fix.php
Last active August 29, 2015 14:00
Must-use plugin for a quick and dirty work around for HHVM indexing cookies by name and overwriting WordPress's logged_in and auth cookies.
<?php
/**
* Plugin Name: WP HHVM setcookie fix
* Plugin URI: http://bitpiston.com/
* Description: Quick n dirty alternative to setcookie() to work around HHVM indexing cookies by name and overwriting multiple cookies of the same name
* Author: BitPiston Studios
* Author URI: http://bitpiston.com/
* Version: 1.0
* Licence: BSD
*/
@chrismccord
chrismccord / gist:9434b8fa208b3aae22b6
Last active August 29, 2015 14:13
Phoenix Upgrade Instructions 0.7.x to 0.8.0

Channel Changes

The channel layer received significant features and an overhaul of the topic abstraction. Upgrade your 0.7.x channels should only require a few simple steps.

Notable changes:

  • An updated version of phoenix.js is required, replace your priv/static/js/phoenix.js with https://github.com/phoenixframework/phoenix/blob/v0.8.0/priv/static/js/phoenix.js
  • "topic" is now just an identifier. You join topics, broadcast on topics, etc. Channels are are dispatched to based on topic patterns in the router.
  • Channel callbacks in 0.8.0 introduce the concept of outgoing events. Prior to 0.8.0, chanenls only processed incoming events via the event/3 callbacks. In 0.8.0, event/3 has been renamed to handle_in/3, and outgoing events callbacks can be defined via handle_out/3
  • All channel callbacks, such as join/3, leave/2, handle_in/3, and handle_out/3 now accept the socket as the last argument. This mimicks GenServer APIs
  • The return signature of handle_in, `handle_
@jeremy-w
jeremy-w / pipe.rs
Last active August 29, 2015 14:27
Implements Elixir's |> for Rust as pipe!.
/*
* Compile with:
* rustc -Z unstable-options --pretty expanded pipe.rs
*/
/* @file pipe.rs
* @author Jeremy W. Sherman (GitHub: @jeremy-w)
* @license ISC
*
* Implements and demonstrates use of the "pipe" (aka "thread-first") macro.
*/
Kaminari.configure do |config|
# config.default_per_page = 25
# config.max_per_page = nil
# config.window = 4
# config.outer_window = 0
# config.left = 0
# config.right = 0
# config.page_method_name = :page
# config.param_name = :page
end
@jeremy-w
jeremy-w / blurb.fish
Created March 10, 2017 20:00
Fish function to create or reply to a social post on 10 Centuries. MPLv2
function blurb --description Post\ to\ 10C.\\nblurb\ post\ MESSAGE\\nblurb\ POST_ID\ REPLY --argument reply_id message
set -l token $TEN_CENTURIES_API_TOKEN
set -l endpoint https://api.10centuries.org/content/write
set -l usage 'blurb: post or reply to a message on 10C
Usage:
blurb post MESSAGE
Post a new blurb
@joshrieken
joshrieken / Gulpfile.js
Last active July 10, 2019 15:33
Replacing Brunch with Gulp in Phoenix
// Contains support for: SASS/SCSS, concatenation, and minification for JS and CSS
var gulp = require('gulp');
var sass = require('gulp-ruby-sass');
var concat = require('gulp-concat');
var compress = require('gulp-yuicompressor');
module PumaCapacityToCloudwatch
require 'puma_capacity_to_cloudwatch/utilization'
require 'puma_capacity_to_cloudwatch/publish'
class Error < StandardError; end
def self.run
sleep 10 # wait for puma to boot up
return unless defined?(Puma)
@marcoarment
marcoarment / ATPLogoView.m
Created April 29, 2014 21:07
Source for the Accidental Tech Podcast (ATP) T-Shirt
// Source for the Accidental Tech Podcast (ATP) T-Shirt:
// http://www.marco.org/2014/04/29/atp-shirts
//
// By Marco Arment, April 28, 2014. MIT license.
@implementation ATPLogoView
- (void)drawRect:(CGRect)rectIgnored
{
NSString *fontName = @"MyriadPro-Semibold";
@potatosalad
potatosalad / hashquiz.rb
Created December 31, 2010 04:36
Ruby quiz for convert hash "dot paths" into actual hash hierarchy.
#require 'rubygems'
require 'pp'
#require 'ap' # Awesome Print
class Object
# expects [ [ symbol, *args ], ... ]
def recursive_send(*args)
args.inject(self) { |obj, m| obj.send(m.shift, *m) }
end
end
@maxim
maxim / rails_load_path_tips.md
Last active April 13, 2023 13:28
How to use rails load paths, app, and lib directories.

In Rails 3

NOTE: This post now lives (and kept up to date) on my blog: http://hakunin.com/rails3-load-paths

If you add a dir directly under app/

Do nothing. All files in this dir are eager loaded in production and lazy loaded in development by default.

If you add a dir under app/something/