Skip to content

Instantly share code, notes, and snippets.

@staeke
staeke / simplify-names.js
Created June 19, 2020 18:59
SimplifyNamesPlugin
// This is a hack to just simplify variable namings, because they're ugly, for easier debugging
const HarmonyImportDependency = require('webpack/lib/dependencies/HarmonyImportDependency');
const HarmonyImportSpecifierDependency = require('webpack/lib/dependencies/HarmonyImportSpecifierDependency');
const HarmonyImportSpecifierDependencyTemplate = HarmonyImportSpecifierDependency.Template;
const path = require('path');
const HIDproto = HarmonyImportDependency.prototype;
const HISDTproto = HarmonyImportSpecifierDependencyTemplate.prototype;
const originalGetImportVar = HIDproto.getImportVar;
@chikadance
chikadance / ex2.rb
Created February 8, 2014 07:13
rails: #content_for implement
class C
def content_for(smth, content)
if smth == 'smth'
m do
p "smth #{content}"
end
elsif smth == 'smth2'
m do
p "smth2 #{content}"
end
@chikadance
chikadance / actor.rb
Created February 4, 2014 15:44
custom a error class
require 'timers'
module Celluloid
# Don't do Actor-like things outside Actor scope
class NotActorError < Celluloid::Error; end
# Trying to do something to a dead actor
class DeadActorError < Celluloid::Error; end
# A timeout occured before the given request could complete
@chikadance
chikadance / ex2.rb
Created January 7, 2014 04:07
cells communication
require 'celluloid'
class C
include Celluloid
def wait(c)
if c.attr >= 200
puts "c.attr >= 200"
return "finished"
end
@bryancusatis
bryancusatis / mongoid-no-rails.rb
Created September 17, 2012 15:17 — forked from adamzaninovich/mongoid-no-rails.rb
Using Mongoid without Rails
require 'mongoid'
Mongoid::Config.instance.from_hash({"database" => "oid"})
class Tweeter
include Mongoid::Document
field :user
embeds_many :tweets
end
@Burgestrand
Burgestrand / Gemfile
Created August 10, 2012 09:38
Threaded scraping with Capybara, Webkit and Celluloid
source :rubygems
gem 'pry'
gem 'capybara'
gem 'capybara-webkit'
gem 'celluloid'
@theconektd
theconektd / github.css
Created April 30, 2012 02:11
Github Markdown CSS - for Markdown Editor Preview
body {
font-family: Helvetica, arial, sans-serif;
font-size: 14px;
line-height: 1.6;
padding-top: 10px;
padding-bottom: 10px;
background-color: white;
padding: 30px; }
body > *:first-child {
@ryanlecompte
ryanlecompte / gist:1619490
Created January 16, 2012 06:59
Experimenting with forking and unix sockets in Ruby
require 'base64'
require 'socket'
require 'fileutils'
# UnixSocketForker is an experiment of inter-process communication using
# plain unix sockets to communicate between forked processes and the
# parent process. This can also be done via IO.pipe. In this experiment,
# the jobs are simply random arrays whose sums are calculated in the forked
# worker processes.
class UnixSocketForker
@tyok
tyok / rspec_custom_matcher_capybara.rb
Created November 28, 2011 08:12 — forked from yosemsweet/rspec_custom_matcher_capybara.rb
Capybara matchers in RSpec custom matcher
RSpec::Matchers.define :have_widget_elements_for do |widget|
match do |actual|
puts actual.to_yaml
@errors = {}
expected_elements = {
:widget => ".widget",
:content_type => ".#{widget.content_type}",
:body => ".body",
:title => ".title",
@mhawksey
mhawksey / html5reset.css
Created May 17, 2011 08:36
Instant Google Custom Search Engine
<!DOCTYPE html>
<html lang="en">
<head>
<title>Instant Google Custom Search Engine (CSE)</title>
<meta charset="utf-8">
<meta name="description" content="Google Custom Instant">
<link href="http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="html5reset.css" type="text/css" media="screen">
<link rel="stylesheet" href="style.css" type="text/css" media="screen">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>