Skip to content

Instantly share code, notes, and snippets.

@disem
disem / 0_reuse_code.js
Last active August 29, 2015 14:08
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@disem
disem / lepra-plus-inbox
Created July 8, 2015 09:03
плюсануть в карму весь инбокс
var withProperty = [], els = document.getElementsByTagName('a'), i = 0;
for (i = 0; i < els.length; i++) {
if (els[i].hasAttribute('data-user_id')) {
ajaxObject = new XMLHttpRequest();
ajaxObject.open("POST", "/ajax/user/karma/vote/", true);
ajaxObject.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
ajaxObject.send('user=' + els[i].getAttribute('data-user_id') + '&karma_value=' + 2 + '&csrf_token=' + encodeURIComponent(globals.user.csrf_token));
}
}
@disem
disem / gist:d5f76d716303a1ec73fe
Created August 5, 2015 16:05
CJSON benchmark
<?php
$array = require_once('world_cities_array.php');
var_dump("Test case elements count: " . count($array));
class CJSON
{
protected static function reduceString($str)
{
$str = preg_replace(array(
@disem
disem / 00.howto_install_phantomjs.md
Last active August 29, 2015 14:26 — forked from julionc/00.howto_install_phantomjs.md
How to install PhantomJS on Debian/Ubuntu

How to install PhantomJS on Ubuntu

Version: 1.9.8

Platform: x86_64

First, install or update to the latest system software.

sudo apt-get update
sudo apt-get install build-essential chrpath libssl-dev libxft-dev
@disem
disem / capybara cheat sheet
Created November 7, 2016 13:41 — forked from zhengjia/capybara cheat sheet
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')