Skip to content

Instantly share code, notes, and snippets.

View timmarinin's full-sized avatar

Tim Marinin timmarinin

View GitHub Profile
@timmarinin
timmarinin / coffeescript-cheatsheet.md
Last active August 29, 2015 13:57
Coffeescript Cheatsheet (doge)

Declarations

Variables: muchVar = soValue

Making global var: global.muchVar = soValue

Objects:

muchObj =
 soProp: "wow"
@timmarinin
timmarinin / a. description.md
Last active August 29, 2015 13:57
Foolproof constructor for objects

One of javascript pitfalls is object constructor: if you forgot to add new before your function, it will not be called as constructor, but as usual function.

@timmarinin
timmarinin / gist:9659044
Created March 20, 2014 07:41
<style src="..."> loader

This code allows you to use style tag with src attribute, just like script. Merely for fun. Don't use it on production, because browser could not cache and load styles asynchronously.

(function() {
  var styleTags = document.querySelectorAll('style');
  for (var i = 0, l = styleTags.length; i < l; ++i) {
    (function(el){
      var src = el.getAttribute('src');
 if(src.length &gt; 0) {
@timmarinin
timmarinin / gist:82943bccffd440924649
Created May 26, 2014 11:59
infinity horizontal scroller
infinityScroller = function() {
this.el = $(/*wrapper-class*/);
this.blocks = function() { return this.el.children(/*item class*/) }; //function to prevent jquery snapshot
this.maxShift = this.blocks.length - 3; //only 3 at screen
this.indent(this.indent() - this.shiftPx); //make last first and move off screen
this.blocks().last().detach().insertBefore(this.blocks().first());
};
feedTagsPromo.prototype = {
shiftNum: 0, //counter for left displayed item
var created = new Date(opinion.created), timeFormatted, distance = ~~((new Date() - created) / 86400000);
var hours = created.getHours().toString().length === 1 ? '0' + created.getHours() : created.getHours();
var minutes = created.getMinutes().toString().length === 1 ? '0' + created.getMinutes() : created.getMinutes();
timeFormatted = hours + ':' + minutes;
switch(distance) {
case 0:
break;
case 1:
timeFormatted = "вчера в " + timeFormatted;
break;
@timmarinin
timmarinin / keybase.md
Created October 30, 2014 14:22
keybase.md

Keybase proof

I hereby claim:

  • I am marinintim on github.
  • I am marinintim (https://keybase.io/marinintim) on keybase.
  • I have a public key whose fingerprint is B07D ED9A 36F8 2A85 A96A ED91 B770 90C4 04CD C4A4

To claim this, I am signing this object:

@timmarinin
timmarinin / dabblet.css
Last active August 29, 2015 14:08
Delete semicolon after any rule — only that rule and the next rule would not apply
/* Delete semicolon after any rule — only that rule and the next rule would not apply */
/* @marinintim */
.autosize {
height: auto;
min-width: 20em;
min-height: 4em;
box-sizing: border-box;
overflow: visible;
}
@timmarinin
timmarinin / fixFiles.js
Created November 25, 2014 09:50
node as perl
var cheerio = require('cheerio'),
iconv = require('iconv-lite'),
sizeOf = require('image-size'),
fs = require('fs');
iconv.extendNodeEncodings(); //to use win1251 as node encoding
//extract filename from PHP method
function getFilenameFromGetUrld(str) {
var newStr = str.substr(str.indexOf("'") + 1)
@timmarinin
timmarinin / gist:f2c8c2c960062a9d7a06
Created December 9, 2014 23:00
Sample wpa_cli successful authentication output
<2>Trying to authenticate with 00:55:ab:25:ac:5a (SSID=’WLAN-Network’ freq=2437 MHz)
<2>Trying to associate with 00:55:ab:25:ac:5a (SSID=’WLAN-Network’ freq=2437 MHz)
<2>Associated with 00:55:ab:25:ac:5a
<2>WPA: Key negotiation completed with 00:55:ab:25:ac:5a [PTK=CCMP GTK=CCMP]
<2>CTRL-EVENT-CONNECTED — Connection to 00:55:ab:25:ac:5a completed (reauth) [id=0 id_str=]
@timmarinin
timmarinin / dabblet.css
Created December 16, 2014 13:56
Untitled
.wrapper {
border: 1px solid #111;
white-space: nowrap;
height: 700px;
width: 960px;
}
.left {width: 270px; background: grey; height: 100%;}
.right { width: 690px; height: 100%; position: relative; }
.left, .right {