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
# An idiomatic Ruby mixin to Array-like classes. | |
module ArrayX | |
# A re-implementation of the native `Array#flatten` method. | |
# Returns a one-dimensional flattened version of `self`, | |
# or flattens it to a degree, specified by `level`. | |
# | |
# @param level [Number] level of recursion | |
# @return [Array] flattened array | |
def smoothen(level = -1) | |
return self if level == 0 |
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
% % % == % | |
%= = % % == % | |
# Hint: | |
%%%===%== |
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
// ==UserScript== | |
// @name tut.by nocopy | |
// @namespace http://atzkey.org/ | |
// @version 0.1 | |
// @description Removes the "Full article" link from the copied article text | |
// @author atzkey | |
// @match http*://*.tut.by/* | |
// @grant none | |
// ==/UserScript== |
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
#!/usr/bin/env bash | |
if git rev-parse --verify HEAD >/dev/null 2>&1; then | |
against=HEAD | |
else | |
# Initial commit: diff against an empty tree object | |
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 | |
fi | |
# Add extensions to check here |
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
puts *['()',*0.step(15,2).map{|i|'/'+('* '*3+' '*i)[0,i].scan(/../).shuffle*''+'\\'},'[]'].map{|t|t.center(16)} |
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 context_with_constants(name, object, constants, &block) | |
object ||= Object | |
context "#{name} with constants #{constants.inspect}" do | |
setup do | |
@saved_constants = {} | |
constants.each do |k, v| | |
@saved_constants[k] = object.const_get(k) | |
Kernel::silence_warnings { object.const_set(k, v) } | |
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
## | |
# Passes if +url+ contains +param+ in its query string. | |
# | |
# Example: | |
# assert_url_has_param("http://google.com/?q=RTFM", 'q=RTFM') | |
def assert_url_has_param(url, param, message = nil) | |
message = build_message message, "<?> does not contain param <?>", url, param | |
assert_block message do | |
URI.parse(url).query.split('&').any?{|p| p == param} | |
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
/* | |
String.format extension for JavaScript | |
Next line should give you an idea how to use it: | |
"{1}, {0}!".format("world", "Hello"); | |
*/ | |
String.prototype.format = function() { | |
var formatted = this; | |
for (arg in arguments) { |
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
/* | |
jQuery UI Autocomplete AutoFill extension | |
automatically fills in the input box when only one suggestion is to be shown | |
*/ | |
;(function($) { | |
$.extend($.ui.autocomplete.options, {autoFill: true}); | |
$.extend($.ui.autocomplete.prototype, { | |
_response_original: $.ui.autocomplete.prototype._response, |
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
/* Routine that generates frequencies for all 128 MIDI notes */ | |
#include <stdio.h> | |
#include <math.h> | |
int main() | |
{ | |
float midi[127]; | |
int a = 440; // a is 440 hz... | |
int x; |
NewerOlder