This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function! VimRandomColor() | |
| ruby << RUBY | |
| colors_i_like = %w( BlackSea Jammy Lettuce Maroloccio Zmrok Baycomb Brookstream ) | |
| Vim.command("color #{colors_i_like.shuffle.pop}") | |
| RUBY | |
| endfunction | |
| :command! Rc :call VimRandomColor() | |
| :call VimRandomColor() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <stdint.h> | |
| #define _int uint8_t | |
| _int *quicksort(_int *arr, int size_of_arr) { | |
| if (size_of_arr <= 1) | |
| return arr; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def quicksort(array) | |
| return array if array.size <= 1 | |
| less_than_pivot = [] | |
| greater_than_pivot = [] | |
| pivot_value = array.pop | |
| array.each do |item| | |
| less_than_pivot << item if item <= pivot_value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Hash | |
| def symbolize_keys | |
| replace( keys.inject({}) { |new_hash,key| new_hash[key.to_sym] = self[key]; new_hash } ) | |
| end | |
| def symbolize_keys! | |
| symbolized_hash = keys.inject({}) do |new_hash,key| | |
| new_hash[key.to_sym] = self[key] | |
| new_hash[key.to_sym].symbolize_keys! if new_hash[key.to_sym].respond_to? :symbolize_keys! | |
| new_hash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -module(listcomp). | |
| -export([perms/1]). | |
| % generates all possible letter permutations given a string of letters | |
| perms( [] ) -> [[]]; | |
| perms(Phrase) -> | |
| [ [H|Rest] || | |
| H <- Phrase, | |
| Rest <- perms(Phrase -- [H])]. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Gets the last gist for specified user | |
| # | |
| # last gist [for] <username> - Returns the last gist for specified user | |
| module.exports = (robot) -> | |
| robot.respond /last gist (?:for)? (.+)/i, (msg) -> | |
| username = msg.match[1] | |
| url = "https://api.github.com/users/#{username}/gists" | |
| msg.http(url).get() (err, res, body) -> | |
| gists = JSON.parse(body) | |
| indexed = {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def try_cached_event | |
| unless (id = cookies[Event::IDENTITY_KEY]) && (event = Event.find_by_id(id)) | |
| cookies[Event::IDENTITY_KEY] = { expires: 1.day.ago } | |
| return | |
| end | |
| redirect_to event_participants_url(event) | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| it 'creates a participant after clicking `confirm' do | |
| load_page | |
| click_on '10:00 am' | |
| # Not sure why the ActiveRecord connection is becoming | |
| # stale...probably something to do with the way capybara runs tests | |
| # with selenium. | |
| # | |
| # Symptom that led to the change: | |
| # Running this in isolation without refreshing the connection would |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| validClickElementCallbacks: [ | |
| (el) -> $(el)[0].tagName.match(/li/i) && $(el)[0].className.match(/day/), | |
| (el) -> $(el)[0].tagName.match(/span/i) && $(el)[0].className.match(/remaining/), | |
| (el) -> $(el)[0].tagName.match(/h3/i) | |
| ] | |
| bindEvents: -> | |
| @element.click (e) => | |
| return unless _.any(@validClickElementCallbacks, (fn) -> fn(e.target)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (ns bit-sandbox.core) | |
| ; helper | |
| (defn shifted-byte [int-byte-value, shift-by] | |
| (bit-shift-left | |
| (bit-and int-byte-value 0xFF) | |
| (* shift-by 8))) | |
| ; (+ meat potatoes) |