Skip to content

Instantly share code, notes, and snippets.

View gogromat's full-sized avatar

Alexander Astafurov gogromat

  • Brooklyn, New York
View GitHub Profile
@gogromat
gogromat / PhantomJS.js
Created October 15, 2012 12:18
PhantomJS - rasterize (several viewports)
var page = require('webpage').create();
//page.paperSize = { width: "10cm", height: "10cm" };
var url = 'http://twitter.github.com/bootstrap/';
var sizes = ["1000*1000","600*600","200*200"];
var sizeLength = sizes.length-1;
page.open(url, function(status) {
if (status === 'success') {
for (var i = sizeLength; i>=0; --i) {
console.log(i);
@gogromat
gogromat / PhnatomJS2.js
Created October 19, 2012 03:13
PhantomJS - rasterize
var page = require('webpage').create(),
address,
output,
size;
if (phantom.args.length < 1) {
console.log('Error: Wrong number of parameters provided');
phantom.exit();
}
else {
class Hash
# By default, only instances of Hash itself are extractable.
# Subclasses of Hash may implement this method and return
# true to declare themselves as extractable. If a Hash
# is extractable, Array#extract_options! pops it from
# the Array when it is the last element of the Array.
def extractable_options?
instance_of?(Hash)
end
end
var AllHosts = function() {
var host_items = [];
return {
setHost: function(host) {
host_items.push(host);
},
hasHost: function(id) {
var hasMe = false;
$.each(host_items, function(i, host) {
if (parseInt(host.host_id) === parseInt(id)) {
-/macro fio-dec system, june 1963
007652 640500 szm=sza sma-szf
007652 650500 spq=szm i
007652 761200 clc=cma+cla-opr
- define senseswitch A
- repeat 3, A=A+A
- szs A
- term
- define init A,B
- law B
@gogromat
gogromat / Registering Handlebars Helper.html
Last active December 14, 2015 18:09
Registering Handlebars Helper (similar to Meteor's ">" helper for inner templates, except w/o the data)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset=utf-8 />
<title>Testing Handlebars template</title>
</head>
<body>
<div id="test-handlebars">
@gogromat
gogromat / JSTricks.js
Last active July 11, 2023 16:50
Different JS tricks, features, etc.
// Check if variable is array or object
// (From underscore.js each() implementation)
var array = [];
var object = {a:1,b:2};
if (obj == null) return;
//actually it is logically equivalent to this ugliness: if ((obj === null) || (obj === undefined))
// creates a binary Array Buffer
// (нельзя просмотреть просто так, нужен ArrayBufferView)
var buffer = new ArrayBuffer(10),
// (unsigned = capable of representing only non-negative integers [0,oo) )
ex = new Uint8Array(buffer);
// Ex. Size 8-bit (Uint8Array)
// 0 0 0 0 0 0 0 0
// 128 64 32 16 8 4 2 1 [low=0|high=255|total=256]
Jason("sample", sample_data).sample.flatten().getJsonData();