Skip to content

Instantly share code, notes, and snippets.

View belgoros's full-sized avatar

Serguei Cambour belgoros

View GitHub Profile
@belgoros
belgoros / pr.md
Created July 19, 2016 07:44 — forked from piscisaureus/pr.md
Checkout github pull requests locally

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@belgoros
belgoros / remove_nodejs.md
Last active November 4, 2017 09:36
Remove node JS from OS X

The best way (I've found) to completely uninstall node + npm is to do the following:

Go to /usr/local/lib and delete any node and node_modules:

cd /usr/local/lib
sudo rm -rf node*

Go to /usr/local/include and delete any node and node_modules directory:

@belgoros
belgoros / json_response.md
Last active December 4, 2017 14:50
JSON response example

I tried to test a single action:

public class ListsController extends APIController  {

    public void index(){
        view("lists", List.findAll().orderBy("id"));
        render().contentType("application/json");
    }
}
@belgoros
belgoros / a-teeny-component.component.js
Created October 26, 2018 15:09 — forked from NullVoxPopuli/a-teeny-component.component.js
Example of passing actions from controller to nested component
import Ember from 'ember';
export default Ember.Component.extend({
// this component only received args from the caller
// but it does track its own local info property
info: '', // initial form field value
});
@belgoros
belgoros / components.a-teeny-component.js
Created October 26, 2018 15:09 — forked from jenweber/components.a-teeny-component.js
Example of passing actions from controller to nested component
import Ember from 'ember';
export default Ember.Component.extend({
});
// 20181203173529
// http://localhost:3000/apidocs
{
"swagger": "2.0",
"info": {
"version": "1.0.0",
"title": "Example Project API",
"description": "A Swagger Project API that uses a bla-bla-bla project features in commliance with the swagger-2.0 specification",
"contact": {
@belgoros
belgoros / regexCheatsheet.js
Created January 15, 2019 08:35 — forked from sarthology/regexCheatsheet.js
A regex cheatsheet 👩🏻‍💻 (by Catherine)
let regex;
/* matching a specific string */
regex = /hello/; // looks for the string between the forward slashes (case-sensitive)... matches "hello", "hello123", "123hello123", "123hello"; doesn't match for "hell0", "Hello"
regex = /hello/i; // looks for the string between the forward slashes (case-insensitive)... matches "hello", "HelLo", "123HelLO"
regex = /hello/g; // looks for multiple occurrences of string between the forward slashes...
/* wildcards */
regex = /h.llo/; // the "." matches any one character other than a new line character... matches "hello", "hallo" but not "h\nllo"
regex = /h.*llo/; // the "*" matches any character(s) zero or more times... matches "hello", "heeeeeello", "hllo", "hwarwareallo"
@belgoros
belgoros / lucky_setup.txt
Created February 6, 2019 14:52
Errors when running bin/setup to set up a new Lucky project
lucky-blog git:(master) bin/setup
▸ Installing node dependencies
warning laravel-mix > autoprefixer > browserslist@2.11.3: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning laravel-mix > css-loader > cssnano > autoprefixer > browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning laravel-mix > css-loader > cssnano > postcss-merge-rules > browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning laravel-mix > css-loader > cssnano > postcss-merge-rules > caniuse-api > browserslist@1.7.7: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
warning "laravel-mix > img-loader@3.0.1" has unmet peer dependency "imagemin@^5.0.0 || ^6.0.0".
@belgoros
belgoros / Guardian JWT.md
Created October 24, 2019 14:04 — forked from nikneroz/Guardian JWT.md
Elixir + Phoenix Framework + Guardian + JWT. This is tutorial and step by step installation guide.

Elixir + Phoenix Framework + Guardian + JWT + Comeonin

Preparing environment

We need to generate secret key for development environment.

mix phoenix.gen.secret
# ednkXywWll1d2svDEpbA39R5kfkc9l96j0+u7A8MgKM+pbwbeDsuYB8MP2WUW1hf

Let's generate User model and controller.

@belgoros
belgoros / example.rb
Last active November 19, 2019 16:28
AMS for a non-AR model, Rails 5.2.3
# models/user.rb
class User
include ActiveModel::Model
attr_accessor :username, :first_name, :last_name, :id
end
#serializers/user_serializer.rb
class UserSerializer < ActiveModelSerializers::Model
attributes :id, :first_name, :last_name, :username