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 / 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 / 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 / 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("");
};
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
# 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 ->
@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)
@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 / 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

after install neovim nvim config file folder ~/.config/nvim

git clone https://github.com/VundleVim/Vundle.vim.git ~/.config/nvim/bundle/Vundle.vim
ln -s ~/.vimrc ~/.config/nvim/init.vim
vim ~/.vimrc
set nocompatible              " be iMproved, required

filetype off " required

@RANUX
RANUX / purgeAndroid.txt
Created June 21, 2017 13:15 — forked from tahmidsadik/purgeAndroid.txt
How to completely remove Android Studio from Mac OS X
How to Completely Remove Android Studio
Execute these commands from the terminal
rm -Rf /Applications/Android\ Studio.app
rm -Rf ~/Library/Preferences/AndroidStudio*
rm ~/Library/Preferences/com.google.android.studio.plist
rm -Rf ~/Library/Application\ Support/AndroidStudio*
rm -Rf ~/Library/Logs/AndroidStudio*