Skip to content

Instantly share code, notes, and snippets.

View yogurt1's full-sized avatar
🦦

Paruyr yogurt1

🦦
View GitHub Profile
class Class
bar: -> console.log @a
class SubClass extends Class
inst = new SubClass
inst.a = 10
inst.bar() # => 10
@yogurt1
yogurt1 / body.pug
Last active August 11, 2016 11:35
Best template ever
body.hold-transition.skin-green.sidebar-mini
.wrapper
// Шапка
header.main-header
// Логотип
a.logo(href='#')
span.logo-mini
b Н
| К
span.logo-lg
@yogurt1
yogurt1 / sort.cpp
Created September 29, 2016 19:14
Sort from god
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
int main(void) {
std::ios::sync_with_stdio(false);
int len;
std::cin >> len;
std::vector<int> vec(201);
@yogurt1
yogurt1 / sort_ansi.c
Last active September 29, 2016 22:31
Sort from God, ANSI C version
#include <stdlib.h>
#include <stdio.h>
int main(void) {
int len;
scanf("%d", &len);
/* malloc array of ints */
int* arr = (int*)malloc(201 * sizeof(int));
for (int t, i = 0; i < len; i++) {
@yogurt1
yogurt1 / db_promise.js
Created October 20, 2016 20:13
Promise guide
function someHander(req, res, next) {
db.any('select * from users')
.then((data, cb) => {
let red = []
data.forEach(row => {
red[i] = row.username
})
res.json({
red
})
@yogurt1
yogurt1 / babel.preset.js
Created December 4, 2016 17:41
my custom babel preset
const preset = buildPreset()
Object.defineProperty(preset, "buildPreset", {
configurable: true,
writable: true,
enumerable: false,
value: buildPreset
})
module.exports = preset
function buildPreset(opts = {}) {
@yogurt1
yogurt1 / Chat.js
Last active December 14, 2016 08:15
Chat in pure Node.js at backend and Vanilla.js at frontend
var http = require("http");
var msgs = []; // All messages array
var subscribers = []; // All subscribers array
var PORT = process.env.PORT || 8080;
// Create HTTP server
var server = http.createServer(function(req, res) {
// Small router
switch(req.url) {
case "/":
@yogurt1
yogurt1 / ui-height.js
Last active November 27, 2017 10:22
webogram scroll
var atBottom = true
var scrollTopInitial = -1
$(scrollableWrap).on('scroll', function (e) {
if (!element.is(':visible') ||
$(scrollableWrap).hasClass('im_history_to_bottom') ||
curAnimation) {
return
}
var st = scrollableWrap.scrollTop
atBottom = st >= scrollableWrap.scrollHeight - scrollableWrap.clientHeight
@yogurt1
yogurt1 / Memoization.jsx
Last active February 19, 2018 01:45
React <Memoization />
import React from 'react';
import PropTypes from 'prop-types';
class Memoization extends React.Component {
lastInput = null;
result = null;
render() {
const { equals, input, compute, children } = this.props;
@yogurt1
yogurt1 / pwgen.sh
Last active May 14, 2018 17:39
pwgen bash edition
# How to use: sh pwgen.sh <password length, default 9>
_LENGTH=9
if test x"$@" != x
then _LENGTH="$@"
fi
cat /dev/urandom |\
tr -dc 'A-Za-z0-9' |\
fold -w $_LENGTH |\
#-w 20 |\