Skip to content

Instantly share code, notes, and snippets.

@asm-jaime
asm-jaime / es6_counter_react.js
Last active August 13, 2016 08:48
easy es6/state/props react counter, full project on github.com/asm-jaime/easy-react
'use strict';
const React = require('react');
const ReactDOM = require('react-dom');
export class Counter extends React.Component {
constructor(props) {
super(props);
this.state = {count: props.initialCount};
this.tick = this.tick.bind(this);
}
@asm-jaime
asm-jaime / fizz_buzz.js
Created August 15, 2016 02:32
easy fizz buzz realization
'use strict'
let rem = true;
for(let i = 1; i<101; ++i){
if(!(i%3)){console.log("Fizz"); rem = false;};
if(!(i%5)){console.log("Buzz"); rem = false;};
if(!(i%15)){console.log("FizzBuzz"); rem = false;};
if(rem)console.log(i);
rem = true;
}
@asm-jaime
asm-jaime / .tern-project
Last active August 17, 2016 23:43
.tern-project vim for node.js development
{
"ecmaVersion": 6,
"defs": [
"browser",
"ecma5",
"ecma6"
],
"dontLoad": [
"node_modules/**"
],
@asm-jaime
asm-jaime / .editorconfig
Created August 16, 2016 15:16
.editorconfig use config with vim for jsbeautify
;.editorconfig
root = true
[**.js]
; path to optional external js beautifier, default is vim-jsbeautify/plugin/lib
path=/usr/local/lib/node_modules/js-beautify/js/lib/beautify.js
; Javascript interpreter to be invoked by default 'node'
bin = node
e4x = true
@asm-jaime
asm-jaime / upd_object.js
Created August 17, 2016 16:49
updating array objects from otcher objects on id
'use strict'
const objects = [{
channel: {
id: "first"
}
}, {
channel: {
id: "second",
props: "old value"
@asm-jaime
asm-jaime / rating_in_shool.js
Created August 27, 2016 11:44
best learner in school, without sort
"use strict";
const shool_rating = [
"Вова Петькин 2 2 3",
"Митька Залупкин 2 2 2",
"Антон Газенвагович 5 5 3",
"Антон Залупкин 2 2 3",
"Вова Залупкин 2 4 3",
"Вова Петькин 3 3 2"
];
@asm-jaime
asm-jaime / enum_obj.js
Created August 29, 2016 21:12
enumeration object (JavaScript)
const abstract_object = {
first_pro : "first",
second_pro : "second",
third_pro : "third"
};
Object.keys(abstract_object).map((num, index) => {
abstract_object[num] = index+1;
});
console.log(abstract_object);
@asm-jaime
asm-jaime / css-to-react-inline-css.md
Last active September 12, 2016 20:19
regular expression (regExp, vim), convert easy css to react inline-css
  1. %s/\(-\)\(\w\)/\U\2/g - replace something like font-size to fontSize
  2. %s/\(: \)\(.\+\);/\1"\2",/g - replace something like 25px; to "25px", fontSize
@asm-jaime
asm-jaime / signs_digits .c
Last active September 20, 2016 20:19
place plus/minus signs between the digits (on C)
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int current_sum = 0;
/* return pointer on vector with random numbers*/
int* get_rnd1d_vector(const int *count_num, const int *max_num){/*{{{*/
int* vector = malloc((*count_num) * sizeof(int));
for (int i = 0; i < (*count_num); ++i)
@asm-jaime
asm-jaime / E212.md
Created September 25, 2016 08:16
vim, if error when you save a file.

: w !sudo tee % &gt; /dev/null