Skip to content

Instantly share code, notes, and snippets.

Avatar
🌵

Paruyr yogurt1

🌵
View GitHub Profile
@yogurt1
yogurt1 / pwgen.sh
Last active May 14, 2018
pwgen bash edition
View pwgen.sh
# 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 |\
View subclass.coffee
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 Aug 11, 2016
Best template ever
View body.pug
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 Sep 29, 2016
Sort from god
View sort.cpp
#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 Sep 29, 2016
Sort from God, ANSI C version
View sort_ansi.c
#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++) {
View db_promise.js
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 Dec 4, 2016
my custom babel preset
View babel.preset.js
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 Dec 14, 2016
Chat in pure Node.js at backend and Vanilla.js at frontend
View Chat.js
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 Nov 27, 2017
webogram scroll
View ui-height.js
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 Feb 19, 2018
React <Memoization />
View Memoization.jsx
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;
You can’t perform that action at this time.