Skip to content

Instantly share code, notes, and snippets.

View Paxa's full-sized avatar

Pavel Evstigneev Paxa

View GitHub Profile
@Paxa
Paxa / convert.rb
Created March 21, 2013 04:32
Convert all sass files to right syntax
files = Dir['**/**.sass']
files.each do |file|
old_style = `sass-convert -F sass -T sass --old #{file}`
old_style.gsub!(/(?<=\S)[\t ]+$/, '')
File.open(file, 'w:utf-8') do |f|
f.write old_style
end
puts file
end
@Paxa
Paxa / is_haml_benchmark.rb
Created July 11, 2013 07:29
Benchmarking HAML with RubyVM::InstructionSequence
# benchmark haml templates compiled with RubyVM::InstructionSequence
require "rubygems"
require "bundler/setup"
require "haml"
require "rbench"
class ViewHelpers
include Haml::Helpers
@Paxa
Paxa / gist:8080098
Created December 22, 2013 09:15
Textmate/sublime command to format markdown table
#!/usr/bin/env ruby
def format_table(table_str)
lines = table_str.split("\n")
collumn_widths = []
collumn_aligns = []
lines.each_with_index do |line, line_no|
line.split("|").each_with_index do |column_data, col_no|
column_data = column_data.strip
if line_no == 1
@Paxa
Paxa / _wget.md
Last active April 1, 2020 04:25
Cross-compiling wget for blackberry 10 (QNX)

How to compile wget for blackberry 10

Prepare

  1. Download from here http://ftp.gnu.org/gnu/wget/
  2. Extract sources archive, (using extract for example)
  3. Or run tar xf wget-1.15.tar.xz
  4. Copy file bb10_compile from this gist to source folder

Compile

@Paxa
Paxa / bb10_compile
Created February 13, 2014 04:13
ruby for blackberry 10
#! /bin/sh
tmp_pwd=`pwd`
cd /Applications/Momentics.app && source bbndk-* && cd $tmp_pwd
echo $QNX_HOST
QNX_BINS="${QNX_HOST}/usr/bin"
#
ActiveAdmin::Dashboards.build do
# Add this section in your dashboard...
section "Background Jobs" do
now = Time.now.getgm
ul do
li do
jobs = Delayed::Job.where('failed_at is not null').count(:id)
link_to "#{jobs} failing jobs", admin_jobs_path(q: {failed_at_is_not_null: true}), style: 'color: red'
end
@Paxa
Paxa / 0.result for ruby
Last active August 29, 2015 13:58
Ruby and nodejs http library benchmark
[em-http-request, HTTParty, Net::HTTP, Net::HTTP (persistent), open-uri, RestClient, Typhoeus, Excon, Excon (persistent), Curb, Patron (persistent)]
+------------------------+----------+
| tach | total |
+------------------------+----------+
| Patron (persistent) | 0.223029 |
+------------------------+----------+
| Curb | 0.235344 |
+------------------------+----------+
| Typhoeus | 0.389802 |
@Paxa
Paxa / 1.rb
Last active August 29, 2015 14:03
This make class-level method "cached" what makes that method cachable
module CachableMethod
def cachable(merhod_name)
#aliased_merhod_name = :"uncached_#{merhod_name}"
#alias_method aliased_merhod_name, merhod_name
method_proc = instance_method(merhod_name)
ivar_name = :"@#{merhod_name}"
define_method(merhod_name) do |*args, &proc|
if instance_variable_defined?(ivar_name)
@Paxa
Paxa / 1.downloaders.md
Last active April 19, 2016 02:17
nwjs (node-webkit) extra libraries

I search all npm packages related to node-webkit, I may had miss something

NWJS Dowloaders and runners

nw

Installer and runner helper for nw.js. Allows run nwjs project by just typing nw in app folder.

nw-download

Just download helper for nwjs

@Paxa
Paxa / pg_load.js
Last active August 29, 2015 14:20
node-postgres and node-pg-native
if (pg_native) {
var async = require('async');
pg = {
connect: function (connectString, callback) {
var client = new pg_native;
client.original_query = client.query;
client.sqlQueue = async.queue(function (sql, callback) {