Skip to content

Instantly share code, notes, and snippets.

View dgutov's full-sized avatar

Dmitry Gutov dgutov

View GitHub Profile
@dgutov
dgutov / test.cpp
Created October 12, 2015 15:00
Semantic bug
struct foo {
int a;
int b;
};
struct bar {
int c;
int d;
};
@dgutov
dgutov / Gemfile
Created April 20, 2015 14:47
Tabs or Spaces
source :rubygems
group :development do
gem 'pry'
end
gem 'yajl-ruby'
gem 'em-synchrony'
gem 'em-http-request'
@dgutov
dgutov / scenario.rb
Last active August 29, 2015 14:17
CollectionAssociation#merge_target_lists trouble
require 'active_record'
ActiveRecord::Base.establish_connection(adapter: "sqlite3",
database: ":memory:")
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :widgets do |t|
t.string :name
@dgutov
dgutov / company-quickhelp.el
Last active November 2, 2019 18:59
Show doc with pos-tip
;;; WIP, somewhat usable
(require 'company)
(require 'pos-tip)
(defun company-quickhelp-frontend (command)
"`company-mode' front-end showing documentation in a
`pos-tip' popup."
(pcase command
(`post-command (company-quickhelp--set-timer))
(`hide
@dgutov
dgutov / Fraction.h
Created June 14, 2014 23:43
Objective-C sample
#import <Foundation/NSObject.h>
@interface Fraction: NSObject {
int numerator;
int denominator;
}
-(void) print;
-(void) setNumerator: (int) n;
-(void) setDenominator: (int) d;
@dgutov
dgutov / noisy-typer.el
Created March 13, 2014 07:03
Make noises when typing
;;; noisy-typer.el --- Make noises when typing -*- lexical-binding: t -*-
;; This file is not part of GNU Emacs.
;; This file is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; This file is distributed in the hope that it will be useful,
require 'excon'
# require 'webmock'
# WebMock.allow_net_connect!
s = StringIO.new("muffins")
resp = Excon.put("http://localhost:9292", request_block: lambda { s.read(2).to_s })
puts resp.body
@dgutov
dgutov / bob_bm.rb
Created August 10, 2013 18:54
Bob vs Bob
require 'benchmark'
class Bob
def hey(msg)
case msg
when nil, ""
"Fine. Be that way!"
when /\A[^a-z]+\z/
"Woah, chill out!"
when /\?\z/
@dgutov
dgutov / company-mode-spartan.el
Created May 21, 2013 23:03
company-mode, Spartan Edition
(setq company-frontends '(company-echo-strip-common-frontend)
company-require-match nil
company-backends '(company-capf))
(define-key company-mode-map (kbd "C-M-i") 'company-complete)
@dgutov
dgutov / app.rb
Created May 12, 2013 19:59
Rack::Protection::SessionHijacking video tag false positive
require "sinatra"
require "pry"
enable :sessions
set :session_secret, "cupcakes"
get "/" do
session[:sheep] ||= 0
session[:sheep] += 1
erb :index