Skip to content

Instantly share code, notes, and snippets.

View moondef's full-sized avatar
:octocat:

Stepan Samko moondef

:octocat:
View GitHub Profile
@moondef
moondef / .gitattributes
Created March 30, 2018 17:48
Gist for setting language
*.html linguist-language=JavaScript
@moondef
moondef / getAngle.js
Last active June 22, 2018 13:06
Get angle between arrows
const getAngle = (hour, min) => Math.abs(30 * ((hour % 12) + min / 60) - min * 6);
const balancedNum = number => {
const str = number.toString();
const getMiddle = s => {
const splited = s.split('');
if (splited.length % 2 === 0) {
return splited[splited.length / 2 - 1] + splited[splited.length / 2];
} else {
return splited[Math.floor(splited.length / 2)];
}

Keybase proof

I hereby claim:

  • I am moondef on github.
  • I am moondef (https://keybase.io/moondef) on keybase.
  • I have a public key ASAW9bhoDdIss5QcCGAWNrmJ0v9Ymhmndj9ZeClLIXMlRQo

To claim this, I am signing this object:

{
"title": "test json",
"data": [
{ "name": "firstName1", "price": 300 },
{ "name": "firstName2", "price": 400 },
{ "name": "firstName3", "price": 500 }
]
}
{
"data": [
{
"id": 0,
"name": "Bulbasaur",
"price": 30,
"image": "https://img.pokemondb.net/artwork/bulbasaur.jpg",
"type": ["grass", "poison"],
"species": "Seed Pokemon",
"abilities": [
const addToCart = (cart, pokemon) => {
if (inCart(cart, pokemon)) {
cart.find(item => item.name === pokemon.name).count += 1;
} else {
pokemon['count'] = 1
cart.push(pokemon)
}
return cart
}
@moondef
moondef / qsort.js
Created July 18, 2018 03:05
quick sort
const arr = [1, 4, 2, 5, 200, 6, 9]
const qsort = (arr) => {
if (arr.length < 2) {
return arr
} else {
const pivot = arr[Math.floor(Math.random() * arr.length)]
const less = arr.filter(value => value < pivot)
const greater = arr.filter(value => value > pivot)
{
"presets": ["flow"],
"plugins": [
["react-flow-props-to-prop-types"]
]
}
@moondef
moondef / weirdReverse.js
Last active July 30, 2018 16:09
reverse in 28 symbols
weirdReverse=a=>a.sort(_=>1)