Skip to content

Instantly share code, notes, and snippets.

View ivanlemeshev's full-sized avatar
👨‍💻
Make it correct, make it clear, make it concise, make it fast. In that order.

Ivan Lemeshev ivanlemeshev

👨‍💻
Make it correct, make it clear, make it concise, make it fast. In that order.
  • Espoo, Finland
View GitHub Profile
@ivanlemeshev
ivanlemeshev / javascript_resources.md
Last active August 29, 2015 14:19 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@ivanlemeshev
ivanlemeshev / rails_resources.md
Last active August 29, 2015 14:19 — forked from jookyboi/rails_resources.md
Rails-related Gems and guides to accelerate your web project.

Gems

  • Bundler - Bundler maintains a consistent environment for ruby applications. It tracks an application's code and the rubygems it needs to run, so that an application will always have the exact gems (and versions) that it needs to run.
  • rabl - General ruby templating with json, bson, xml, plist and msgpack support
  • Thin - Very fast and lightweight Ruby web server
  • Unicorn - Unicorn is an HTTP server for Rack applications designed to only serve fast clients on low-latency, high-bandwidth connections and take advantage of features in Unix/Unix-like kernels.
  • SimpleCov - SimpleCov is a code coverage analysis tool for Ruby 1.9.
  • Zeus - Zeus preloads your Rails app so that your normal development tasks such as console, server, generate, and specs/tests take less than one second.
  • [factory_girl](h
<?php
$encodedData = str_replace(' ', '+', $encodedData);
$decodedData = base64_decode($encodedData);
@ivanlemeshev
ivanlemeshev / tail-call-fibonacci.js
Created August 4, 2015 16:32
JS: Tail-Call Fibonacci
function fibonacci(n) {
var fibonacciItr = function(a, b, n) {
if (n === 0) return a;
return fibonacciItr(b, a + b, n - 1);
};
return fibonacciItr(0, 1, n);
}
@ivanlemeshev
ivanlemeshev / wkhtmltopdf.md
Created August 26, 2015 09:54
HTML to PDF
$url = 'http://google.com';
$command = 'cd /path/to/pdf && wkhtmltopdf.sh ' . $url . ' filename.pdf';

exec($command);

if (file_exists("/path/to/pdf/filename.pdf")) {
    header('Content-type: application/pdf');
    header('Content-Disposition: attachment; filename="filename.pdf"');
 readfile('/path/to/pdf/filename.pdf');
@ivanlemeshev
ivanlemeshev / hexlet.slack.md
Last active August 26, 2015 19:48
тестирование

kirill.mokevnin [01:17] кстати, у хекслета ведь скрытая цель приучить людей к тестированию), вы все волей не волей сталкиваетесь с тестами и кто то даже изучает что там происходит, или что в итоге надо сделать.

kirill.mokevnin [01:18] Так вот эти тесты в нашей практике, они помогли кому то понять тестирование? Начать писать тесты?

ivanlemeshev [01:20] да, периодически в них смотрю, но писать не начал (

pgavrilov [01:21]

@ivanlemeshev
ivanlemeshev / gulpfile.js
Created August 27, 2015 12:12
gulpfile.js
'use strict';
var gulp = require('gulp'),
wiredep = require('wiredep'),
concat = require('gulp-concat'),
csso = require('gulp-csso'),
uglify = require('gulp-uglify'),
ngAnnotate = require('gulp-ng-annotate'),
livereload = require('gulp-livereload'),
jscs = require('gulp-jscs'),
@ivanlemeshev
ivanlemeshev / application.html.slim
Created November 18, 2015 17:58 — forked from hmans/application.html.slim
Application layout for Rails (4), Slim style.
doctype html
html
head
title My App
meta name="viewport" content="width=device-width, initial-scale=1.0"
= stylesheet_link_tag "application", media: 'all', 'data-turbolinks-track' => true
= javascript_include_tag "application", 'data-turbolinks-track' => true
= csrf_meta_tags
body
@ivanlemeshev
ivanlemeshev / rspec_rails_cheetsheet.rb
Created November 18, 2015 19:18 — forked from them0nk/rspec_rails_cheetsheet.rb
Rspec Rails cheatsheet (include capybara matchers)
#Model
@user.should have(1).error_on(:username) # Checks whether there is an error in username
@user.errors[:username].should include("can't be blank") # check for the error message
#Rendering
response.should render_template(:index)
#Redirecting
response.should redirect_to(movies_path)
@ivanlemeshev
ivanlemeshev / gist:e16a863b7ee7872d6bda
Created December 18, 2015 12:02 — forked from jonathanmoore/gist:2640302
Get the share counts from various APIs

Share Counts

I have always struggled with getting all the various share buttons from Facebook, Twitter, Google Plus, Pinterest, etc to align correctly and to not look like a tacky explosion of buttons. Seeing a number of sites rolling their own share buttons with counts, for example The Next Web I decided to look into the various APIs on how to simply return the share count.

If you want to roll up all of these into a single jQuery plugin check out Sharrre

Many of these API calls and methods are undocumented, so anticipate that they will change in the future. Also, if you are planning on rolling these out across a site I would recommend creating a simple endpoint that periodically caches results from all of the APIs so that you are not overloading the services will requests.

Twitter