Skip to content

Instantly share code, notes, and snippets.

@eguneys
eguneys / sample.txt
Created December 31, 2013 07:41
Sample Gist
My first sample gist
@eguneys
eguneys / gulpfile.js
Created July 25, 2014 07:21
Package files by folder with gulp
gulp.task('build-dev-templates5', function() {
var mergeStream = require('merge-stream');
var fs = require('fs');
var amdModulePrefix = 'define(["ember"], function(Ember) {',
amdModulePostfix = '});';
var directoryFilter = $.filter(function (file) { return file.isDirectory(); });
@eguneys
eguneys / gesture.js
Created August 31, 2014 11:37
A Gesture Manager for Phaser.
'use strict';
define(['phaser'], function(Phaser) {
function Gesture(game) {
this.game = game;
this.swipeDispatched = false;
this.holdDispatched = false;
this.isTouching = false;
@eguneys
eguneys / gulpfile.js
Created September 1, 2014 16:53
gulpfile test task hangs
'use strict';
// npm install --save-dev gulp gulp-load-plugins gulp-util gulp-autoprefixer gulp-cache gulp-imagemin main-bower-files gulp-filter gulp-ignore gulp-flatten gulp-csso gulp-useref gulp-if gulp-uglify gulp-rimraf gulp-size gulp-jshint jshint-stylish gulp-livereload gulp-nodemon wiredep bower-requirejs requirejs gulp-debug gulp-changed gulp-concat gulp-ember-templates gulp-insert gulp-plumber merge-stream gulp-sass gulp-grep-stream gulp-rename rimraf mv
var gulp = require('gulp');
var $ = require('gulp-load-plugins')({
pattern: '{gulp-*,main-*}'
});
var runSequence = require('run-sequence');
var rimraf = require('rimraf');
@eguneys
eguneys / index.hbs
Created September 17, 2014 09:50
voting app front end with ember
.container
.row
.col-md-12
h3 Sample Vote Application
.lead
{{question}}?
div class="poll-choices {{resultsHidden::hidden}}"
each choices
.row
@eguneys
eguneys / turkish.el
Created October 2, 2014 09:54
Emacs Turkish Mode
(defvar turkish-el-version "$Id: turkish.el,v 2.7 2010/02/27 18:22:36 dyuret Exp $")
;;; Emacs Turkish Extension (c) Deniz Yuret, 2006, 2010
;;; This is for people trying to type Turkish documents on a U.S.
;;; keyboard. The latest version is available at:
;;; http://denizyuret.blogspot.com/2006/11/emacs-turkish-mode.html
;;; To activate the program first load this file into emacs:
;;; M-x load-file ENTER turkish.el ENTER
@eguneys
eguneys / question.md
Last active August 29, 2015 14:08
NodeJS Stream.Readable ArticleReader Question

I have a NodeJS stream.Readable, ArticleReader. It's job is to read articles, Meantime I have to give it a date to signify the date of the articles, say the default date is today, now I start reading with .on('data') event, and the stream ends. Later I want to change the date and start reading yesterday's articles, In what way I should implement this stream.Readable so this is possible.

One way to think about this is, construct a new ArticleReader for each date. Is this a good approach or is there a better way?

Here's a sample implemtation for reference.

var async = require('async'),
    util = require('util'),
    ReadableStream = require('readable-stream').Readable;
@eguneys
eguneys / highlandjunk.js
Created November 9, 2014 15:52
Highland stream consume push within promise fail
var util = require('util'),
cheers = require('cheers'),
_ = require('highland'),
Q = require('q');
function JunkStrat() {}
JunkStrat.prototype.authorStream = function() {
return _(['a', 'b', 'c', 'd']);
};

This is tags controller with a remove action, it is supposed to render remove.js.erb.

class TagsController < ApplicationController
  def remove
    @ticket = Ticket.find(params[:ticket_id])
    if can?(:tag, @ticket.project) || current_user.admin?
      @tag = Tag.find(params[:id])
      @ticket.tags -= [@tag]
 @ticket.save
class Account < ActiveRecord::Base
end
class Partner < ActiveRecord::Base
has_many :accounts
def add_account(attributes)
accounts.create!(attributes) do |r|
r.partner_id = id
end