Skip to content

Instantly share code, notes, and snippets.

Akiko Yokoyama acotie

Block or report user

Report or block acotie

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@acotie
acotie / eventmachine-defer.rb
Last active May 20, 2016
eventmachine defer sample.
View eventmachine-defer.rb
require 'bundler/setup'
require 'eventmachine'
require 'open-uri'
EM.run do
puts "main: #{Thread.current}"
operation = proc {
puts "defer operation: #{Thread.current}"
sleep(20)
@acotie
acotie / entities.rb
Last active Aug 29, 2015
REST API sample by Grape & Grape::Entity. return nested items.
View entities.rb
module TEST::Entities
class Post < Grape::Entity
expose :id
expose :title
expose :description
expose(:image_url) do |post, options|
if post.image.url.present? # else is return null
"http://#{options[:env]['HTTP_HOST']}"+"#{post.image.url}"
end
end
View gist:9109022
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
manager.responseSerializer = [AFJSONResponseSerializer serializer];
manager.requestSerializer = [AFJSONRequestSerializer serializer];
[manager GET:@"http://localhost:3000/api/v1/tracks/1"
parameters:nil
success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"JSON: manager %@", responseObject);
DDLogVerbose(@"Request Successful, responseObject '%@'", responseObject);
View perlbrew cpan configure
$ sudo cpan
Password:
CPAN is the world-wide archive of perl resources. It consists of about
300 sites that all replicate the same contents around the globe. Many
countries have at least one CPAN site already. The resources found on
CPAN are easily accessible with the CPAN.pm module. If you want to use
CPAN.pm, lots of things have to be configured. Fortunately, most of
them can be determined automatically. If you prefer the automatic
configuration, answer 'yes' below.
View Flaskr memo
structure of Flaskr.
├── README
├── TODO
├── flaskr.db
├── flaskr.py
├── flaskr.pyc
├── flaskr_tests.py
├── schema.sql
View bench.pl
#! /usr/bin/perl
use common::sense;
use Benchmark qw/cmpthese/;
use Perl6::Say;
say $^V;
my $datetime = '20101028120000';
cmpthese(1000000, {
unpack => sub {
View mac-memo.txt
sudo port -v selfupdate
sudo port -v sync
sudo port install wget tree proctools git-core
sudo port install nkf
sudo port install subversion
sudo port install vim
sudo port install emacs
sudo port install ImageMagick +lcms +jpeg2
sudo port install graphviz
View DateObject.cfm
<cfscript>
objDate = createobject("java", "java.util.Date");
objCalendar = createobject("java", "java.util.Calendar");
//theDate = now();
//calendar.set(datepart("yyyy",theDate),datepart("m",theDate),datepart("d",theDate),datepart("h",theDate),datepart("n",theDate),datepart("s",theDate));
</cfscript>
<cfdump var="#objDate#">
<cfdump var="#objCalendar#">
View QueryToArray.cfc
<cffunction name="query2array" access="public" output="false" returntype="array" displayname="query2array" hint="query2array (Values only)">
<cfargument name="Querys" type="query" required="yes" />
<cfset var aResults = arrayNew(1)>
<cfloop from="1" to="#arguments.Querys.recordCount#" index="i">
<cfloop list="#arguments.Querys.columnList#" index="columnName">
<cfset aResults[i] = arguments.Querys[columnName][i]>
</cfloop>
</cfloop>
You can’t perform that action at this time.