Skip to content

Instantly share code, notes, and snippets.

View gtkatakura's full-sized avatar

gtkatakura

View GitHub Profile
Remove file from git repository (history)
SOLUTION: This is the shortest way to get rid of the files:
1. check .git/packed-refs - my problem was that I had there a refs/remotes/origin/master line for a remote repository, delete it, otherwise git won't remove those files
2. (optional) git verify-pack -v .git/objects/pack/#{pack-name}.idx | sort -k 3 -n | tail -5 - to check for the largest files
3. (optional) git rev-list --objects --all | grep #{SHA_FROM_#_3} - to check what files those are
@adomokos
adomokos / visitor_pattern_example.rb
Created May 24, 2011 17:28
The Visitor Pattern implementation in Ruby from the Wikipedia example
class CarElement
def accept(visitor)
raise NotImpelementedError.new
end
end
module Visitable
def accept(visitor)
visitor.visit(self)
end
@mattpodwysocki
mattpodwysocki / gist:1012287
Created June 7, 2011 13:47
Alan Kay on OOP
Dr. Alan Kay explains when "object-oriented" was first used and what it means. [] (Meaning of "Object-Oriented Programming" According to Dr. Alan Kay (meaning of OOP objectoriented definition term notion meaning explanation what is)), document, page 721691
http://www.purl.org/stefan_ram/pub/doc_kay_oop_en (permalink) is the canonical URI of this page.
Stefan Ram
Dr. Alan Kay on the Meaning of “Object-Oriented Programming”
(To link to this page, please use the canonical URI "http://www.purl.org/stefan_ram/pub/doc_kay_oop_en" only, because any other URI is valid only temporarily.)
E-Mail of 2003-07-23
Dr. Alan Kay was so kind as to answer my questions about the term “object-oriented programming”.
Clarification of "object-oriented" [E-Mail]

Today, in Ruby, if I want to make a network request, I block

response = Net::HTTP.get("/post/1")

If I want to do multiple requests in parallel, I can use a thread per request

responses = ["/post/1", "/post/2"].map do |url|
@JedWatson
JedWatson / 1-proposal.md
Last active January 2, 2024 17:59
Proposal: adding reverse-relationship population to Mongoose (as implemented in KeystoneJS)

I've developed a useful feature in KeystoneJS that lets you populate a relationship from either side, while only storing the data on one side, and am looking for feedback on whether it is something that could / should be brought back into mongoose itself. (It might be possible to add as a separate package but I suspect there'd be too much rewriting of mongoose internals for that to be a good idea).

I've added this as an issue in mongoose for consideration: #1888 but am leaving this gist in place because the examples are easier to read.

I've used Posts and Categories as a basic, contrived example to demonstrate what I'm talking about here; in reality you'd rarely load all the posts for a category but there are other real world cases where it's less unreasonable you'd want to do this, and Posts + Categories is an easy way to demo it.

The problem

The built-in population feature is really useful; not just for

@thom-nic
thom-nic / build.gradle
Last active November 16, 2023 07:35
find the largest classnames in Spring libraries. Also find FactoryFactories
/**
* Find the longest class names in Spring.
* Also find FactoryFactory classes.
* a goof-off project by @thom_nic
*/
import java.util.jar.*
defaultTasks 'longest', 'factoryfactory'
@samgiles
samgiles / flatMap.js
Created June 20, 2014 11:32
Javascript flatMap implementation
// [B](f: (A) ⇒ [B]): [B] ; Although the types in the arrays aren't strict (:
Array.prototype.flatMap = function(lambda) {
return Array.prototype.concat.apply([], this.map(lambda));
};
@staltz
staltz / introrx.md
Last active May 7, 2024 09:38
The introduction to Reactive Programming you've been missing
@mlanett
mlanett / rails http status codes
Last active May 3, 2024 04:15
HTTP status code symbols for Rails
HTTP status code symbols for Rails
Thanks to Cody Fauser for this list of HTTP responce codes and their Ruby on Rails symbol mappings.
Status Code Symbol
1xx Informational
100 :continue
101 :switching_protocols
102 :processing
@donnut
donnut / currying.md
Last active October 28, 2023 17:58
TypeScript and currying

TypeScript and currying

In functional programming you often want to apply a function partly. A simple example is a function add. It would be nice if we could use add like:

var res2 = add(1, 3); // => 4

var add10To = add(10);
var res = add10To(5); // => 15