Skip to content

Instantly share code, notes, and snippets.

View sigmaray's full-sized avatar

Stanislav Zaleski sigmaray

View GitHub Profile
@abhijith
abhijith / swing.clj
Created December 21, 2009 18:43
miglayout swing clojure experiments
(ns swinger
(:import (java.awt BorderLayout Container Dimension))
(:import (javax.swing JButton JFrame JLabel JPanel JTextField JOptionPane JScrollPane JList ImageIcon JComboBox JSeparator JTable UIManager SwingUtilities AbstractButton JFileChooser JDialog JProgressBar JTabbedPane))
(:import (javax.swing.table AbstractTableModel))
(:import (java.awt.event MouseAdapter MouseListener KeyEvent))
(:import (java.awt Toolkit BorderLayout Dimension Color Dialog$ModalityType))
(:use (clojure.contrib
[miglayout :only (miglayout components)]
[swing-utils :only (add-action-listener add-key-typed-listener make-menubar)])))
@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
(ns example.flash
(:use compojure.core)
(:use ring.util.response)
(:use ring.middleware.session)
(:use ring.middleware.flash)
(:require [compojure.route :as route]))
(defn show-new [flash]
(str "Flash: " flash
"<br/>
@gavinmyers
gavinmyers / cloo.clj
Last active December 27, 2022 10:45
Goop started in Clojure (currently just draws random pixel data, not optimized)
(import javax.swing.JFrame)
(import javax.swing.JPanel)
(import java.awt.event.ActionEvent)
(import java.awt.Dimension)
(import java.awt.Color)
(import javax.swing.Timer)
(import java.awt.event.ActionListener)
(import java.awt.event.KeyListener)
(import java.awt.image.BufferedImage)
(set! *warn-on-reflection* true)
@juanje
juanje / Description.md
Last active November 30, 2023 19:29
Limit Chrome from eating all the memory and CPU

I was tired of Chrome eating all my laptop resources so I decided to put some limit to it with cgroup.

As I was using Ubuntu 12.04 with support for cgroup, I installed the package cgroup-bin and add the following group to the file /etc/cgconfig.conf:

group browsers {
    cpu {
#       Set the relative share of CPU resources equal to 25%
        cpu.shares = "256";
 }
@meagar
meagar / rebase.md
Created April 30, 2014 16:01
Ultimate rebase-onto-master guide

Rebase "web-123-my-branch" onto master:

if you're the only person who is working on a branch...

$ git checkout web-123-my-branch # make sure you're on the right branch
$ git fetch # update remote refs
$ git rebase origin/master # perform the rebase onto the current state of master
  # for each conflict, edit file, resolve conflicts, git add -u <file>, git rebase --continue
$ git push -f origin web-123-my-branch # overwrite remote branch with newly rebase branch
  • Dynamic Dispatch
  • Dynamic Method
  • Ghost Methods
  • Dynamic Proxies
  • Blank Slate
  • Kernel Method
  • Flattening the Scope (aka Nested Lexical Scopes)
  • Context Probe
  • Class Eval (not really a 'spell' more just a demonstration of its usage)
  • Class Macros
@Integralist
Integralist / 0. description.md
Last active June 17, 2023 21:49
Clojure deftype, defrecord, defprotocol
  • defprotocol: defines an interface
  • deftype: create a bare-bones object which implements a protocol
  • defrecord: creates an immutable persistent map which implements a protocol

Typically you'll use defrecord (or even a basic map);
unless you need some specific Java inter-op,
where by you'll want to use deftype instead.

Note: defprotocol allows you to add new abstractions in a clean way Rather than (like OOP) having polymorphism on the class itself,

@treble37
treble37 / step1-testing-elasticsearch.rb
Created February 3, 2015 05:46
Step 1 - Testing ElasticSearch - spec_helper.rb
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
# The generated `.rspec` file contains `--require spec_helper` which will cause this
# file to always be loaded, without a need to explicitly require it in any files.
#
# Given that it is always loaded, you are encouraged to keep this file as
# light-weight as possible. Requiring heavyweight dependencies from this file
# will add to the boot time of your test suite on EVERY test run, even for an
# individual file that may not need all of that loaded. Instead, make a
# separate helper file that requires this one and then use it only in the specs
@logrusorgru
logrusorgru / mysql.sql
Last active January 16, 2024 07:01
SQL: uniqueness, automatic created_at, updated_at refresh + soft delete. SQLite, PostgreSQL, MySQL
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
-- --
-- mysql --
-- --
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
--
-- mysql <http://sqlfiddle.com/#!9/91afb5/2>
-- note: sqlfiddle is very stupid