Skip to content

Instantly share code, notes, and snippets.

View semenyukdmitry's full-sized avatar

Dmitry Semenyuk semenyukdmitry

View GitHub Profile
@OrionReed
OrionReed / dom3d.js
Last active May 9, 2024 01:03
3D DOM viewer, copy-paste this into your console to visualise the DOM topographically.
// 3D Dom viewer, copy-paste this into your console to visualise the DOM as a stack of solid blocks.
// You can also minify and save it as a bookmarklet (https://www.freecodecamp.org/news/what-are-bookmarklets/)
(() => {
const SHOW_SIDES = false; // color sides of DOM nodes?
const COLOR_SURFACE = true; // color tops of DOM nodes?
const COLOR_RANDOM = false; // randomise color?
const COLOR_HUE = 190; // hue in HSL (https://hslpicker.com)
const MAX_ROTATION = 180; // set to 360 to rotate all the way round
const THICKNESS = 20; // thickness of layers
const DISTANCE = 10000; // ¯\\_(ツ)_/¯
@eikes
eikes / gist:5a64b661022c756bd6522ed94770e2a6
Created July 4, 2016 14:02
List of Ruby on Rails Timezone names and their alias
["Africa/Algiers", "West Central Africa"],
["Africa/Cairo", "Cairo"],
["Africa/Casablanca", "Casablanca"],
["Africa/Harare", "Harare"],
["Africa/Johannesburg", "Pretoria"],
["Africa/Monrovia", "Monrovia"],
["Africa/Nairobi", "Nairobi"],
["America/Argentina/Buenos_Aires", "Buenos Aires"],
["America/Bogota", "Bogota"],
["America/Caracas", "Caracas"],
require 'excon'
require 'securerandom'
def multipart_form_data(buildpack_file_path)
body = ''
boundary = SecureRandom.hex(4)
data = File.open(buildpack_file_path)
data.binmode if data.respond_to?(:binmode)
data.pos = 0 if data.respond_to?(:pos=)
@cmaitchison
cmaitchison / after_commit_with_transactional_fixtures.rb
Last active August 4, 2016 03:30 — forked from charleseff/after_commit_with_transactional_fixtures.rb
testing after_commit hooks with transactional fixtures in Rails 4
require 'active_record/connection_adapters/abstract/transaction'
module ActiveRecord
module ConnectionAdapters
class SavepointTransaction < OpenTransaction
def perform_commit_with_transactional_fixtures
commit_records if number == 1
perform_commit_without_transactional_fixtures
end
alias_method_chain :perform_commit, :transactional_fixtures
@44uk
44uk / rserver.rb
Created August 20, 2012 15:34
Ruby Simple Local Server
#!/usr/bin/env ruby
require 'webrick'
srv = WEBrick::HTTPServer.new(
:BindAddress => '127.0.0.1', # '0.0.0.0' allow remote access
:Port => (port = ARGV[0].to_i) === 0 ? 3000 : port,
:DocumentRoot => './',
:DoNotReverseLookup => true
)
trap(:INT){srv.shutdown}
srv.start
@FiloSottile
FiloSottile / dump-imap.py
Created March 12, 2012 13:52
Simple script to dump an IMAP folder into eml files
#!/usr/bin/env python
#-*- coding:utf-8 -*-
import imaplib
import getpass
import argparse
argparser = argparse.ArgumentParser(description="Dump a IMAP folder into .eml files")
argparser.add_argument('-s', dest='host', help="IMAP host, like imap.gmail.com", required=True)
argparser.add_argument('-u', dest='username', help="IMAP username", required=True)

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@ramusus
ramusus / rails_admin.ru.yml
Created February 10, 2012 10:14
Russian translation for RailsAdmin
# Russian. Updated 2012-07-18
ru:
admin:
home:
name: "Главная"
pagination:
previous: "&laquo; Предыдущая"
next: "Следующая &raquo;"
truncate: "…"
@darkleo
darkleo / chunkypixel_average.rb
Created June 27, 2011 19:17
Pixelizing images with ChunkyPNG
#! usr/bin/env ruby
require 'chunky_png'
class ChunkyPNG::Image
# s: Integer (pixel size)
def pixelize s = 10
temp = Array.new((height*1.0/s).ceil) {Array.new((width*1.0/s).ceil) {Array.new(3) {0}}}
height.times {|j| width.times {|i| ChunkyPNG::Color.to_truecolor_bytes(get_pixel(i,j)).each.with_index {|e,k| temp[j/s][i/s][k] += e}}}
png = ChunkyPNG::Image.new width, height
sq = s**2
@jeffkreeftmeijer
jeffkreeftmeijer / bassie.png
Created May 2, 2011 12:25
ChunkyPNG nearest-neighbor resize
bassie.png