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
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);
# basic pfctl control
# ==
# Related: http://www.OpenBSD.org
# Last update: Tue Dec 28, 2004
# ==
# Note:
# this document is only provided as a basic overview
# for some common pfctl commands and is by no means
# a replacement for the pfctl and pf manual pages.
@RANUX
RANUX / MongoDB.md
Created September 14, 2016 18:51 — forked from ldong/MongoDB.md
Learning MongoDB mongodb

Learning MongoDB

Author: Lin Dong

Date: Sun Mar 8 13:36:08 PDT 2015

Lets talk about Mongo, src code

1

Intro

@RANUX
RANUX / reverse-elements.js
Created September 6, 2016 12:59
Reverse elements order with jQuery
$('.video_item_title').toArray().reverse().forEach(
function(i){
console.log($(i).text())
});
@RANUX
RANUX / scroll-insta-subscribers.js
Last active August 16, 2016 17:06
Scroll Instagram Subscribers List in Browser Dev Console.
// Inject jQuery to 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);
function doScroll()
{
$('._4gt3b').scrollTo(0,500000);
}
// начать повторы с интервалом 1,5 сек
var timerId = setInterval(function() {