Skip to content

Instantly share code, notes, and snippets.

View RANUX's full-sized avatar
🏠
👉JavaScript dev. Open for job offerings

Alexander RANUX

🏠
👉JavaScript dev. Open for job offerings
View GitHub Profile
@RANUX
RANUX / homebrew-rvm.md
Created May 10, 2017 14:11 — forked from denji/homebrew-rvm.md
Homebrew + RVM > Awesome

The MBP is my development machine, so I needed all of my tools installed with the ability to update them with ease. In the past, I used MacPorts to take care of my MySQL, Memcached, and Ruby installions and it worked just fine. This time around however, I wanted something new and fun. Homebrew.

Homebrew is a new package manager for OS X. Unlike Fink or MacPorts, Homebrew integrates with the core operating system, reducing the number of extra libraries to install etc. Another neat feature is the ability to write software package recipes in Ruby, awesome.

Here are some raw installation instructions (clean system). I like to keep everything under user ownership to make life more enjoyable, say no to sudo.

You will need the latest version of xcode, you can get it here. After the installation is complete, you may continue.

sudo mkdir /usr/local
@RANUX
RANUX / _custom_grid.sass
Created May 9, 2017 15:25
Simple custom css grid
// Based on https://css-tricks.com/dont-overthink-it-grids/
$pad: 5px
$total-columns: 12
$column-width: 100 / $total-columns
// Column size in percents
// $n - col num
@function grid-column-width($n)
@return ($column-width * $n * 1%)
@RANUX
RANUX / get-vk-groups-urls.js
Last active February 6, 2017 14:27
Get VK group urls in Browser Dev Console
var element1 = document.createElement("script");element1.src = "//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js";element1.type="text/javascript";document.getElementsByTagName("head")[0].appendChild(element1);
var list = [];
$('.labeled>a').each(function(i){
list.push(this.pathname.slice(1));
})
list.forEach(item => {
console.log(item)
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
That’s one of the real strengths of Docker: the ability to go back to a previous commit. The secret is simply to docker tag the image you want.
Here’s an example. In this example, I first installed ping, then committed, then installed curl, and committed that. Then I rolled back the image to contain only ping:
$ docker history imagename
IMAGE CREATED CREATED BY SIZE
f770fc671f11 12 seconds ago apt-get install -y curl 21.3 MB
28445c70c2b3 39 seconds ago apt-get install ping 11.57 MB
8dbd9e392a96 7 months ago 131.5 MB
@RANUX
RANUX / arrayToAscii.js
Created December 6, 2016 12:36
Javascript - convert array with char codes to string
var arrayToAscii = function (arr) {
var res = [];
for (var i = 0; i < arr.length; i++) {
res.push(String.fromCharCode(arr[i]));
}
return res.join("");
};
@RANUX
RANUX / meteor-async.md
Created December 4, 2016 15:54 — forked from possibilities/meteor-async.md
Meteor Async Guide

From Meteor's documentation:

In Meteor, your server code runs in a single thread per request, not in the asynchronous callback style typical of Node. We find the linear execution model a better fit for the typical server code in a Meteor application.

This guide serves as a mini-tour of tools, trix and patterns that can be used to run async code in Meteor.

Basic async

Sometimes we need to run async code in Meteor.methods. For this we create a Future to block until the async code has finished. This pattern can be seen all over Meteor's own codebase:

@RANUX
RANUX / meteor-mongo-examples.js
Last active October 30, 2016 20:46
Meteor and mongo queries examples
// Update or insert a Meteor Collection
doc = Collection.findOne({owner: Meteor.userId()});
doc ? Collection.update({_id: doc._id}, {$set: {field: value}}) : Collection.insert({owner: Meteor.userId(), field: value});
// Count collections
Collection.find({}).count()
@RANUX
RANUX / grid.scss
Last active October 20, 2016 23:57
Пример расчет сетки при помощи SASS
// Взято из CSS фреймворка Skeleton-Sass
// https://github.com/WhatsNewSaes/Skeleton-Sass/blob/master/scss/base/_functions.scss
//
$total-columns: 12; // всего столбоцов (можно задавать любое, но обычно 12)
$column-width: 100 / $total-columns; // ширина одного столбца относительно 100% / общее количество столбцов
$column-margin: 4%; // расстояние между столбцами
// Функция расчитывает размер столбца в процентах
// $n - номер столбца
@function grid-column-width($n) {
@RANUX
RANUX / dabblet.css
Created October 20, 2016 09:58 — forked from csssecrets/dabblet.css
Translucent borders
/**
* Translucent borders
*/
body {
background: url('http://csssecrets.io/images/stone-art.jpg');
}
div {
border: 10px solid hsla(0,0%,100%,.5);