Skip to content

Instantly share code, notes, and snippets.

View pyldin601's full-sized avatar

Román Lakhtadyr pyldin601

View GitHub Profile
const deps1 = {
mongo: [],
tzinfo: ['thread_safe'],
uglifier: ['execjs'],
execjs: ['thread_safe', 'json'],
redis: [],
};
const sortDeps = (depsMap) => {
const reduce = (deps) => deps.reduce(
@pyldin601
pyldin601 / index.d.ts
Created October 7, 2017 06:04
Fluorite Typings v0
// Type definitions for Fluorite.js
// Project: https://github.com/pldin601/Fluorite.js
// Definitions by: Roman Lakhtadyr <[email protected]>
// TypeScript Version: 2.5
import Knex = require('knex');
declare namespace Fluorite {
type Scope = (qb: Knex.QueryBuilder, ...args: Array<any>) => Knex.QueryBuilder;
type Attributes = { [name: string]: any };
@pyldin601
pyldin601 / tmux-cheatsheet.markdown
Created August 22, 2017 12:14 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@pyldin601
pyldin601 / ffmpeg-html5
Created August 16, 2017 14:10 — forked from rjmoggach/ffmpeg-html5
Convert videos to proper formats for HTML5 video on Linux shell using ffmpeg. Will probably convert this to a bash script later, but for the time being, here's some examples. Not sure there have actually sensible dimensions and bitrates for web video.
# webm
ffmpeg -i IN -f webm -vcodec libvpx -acodec libvorbis -ab 128000 -crf 22 -s 640x360 OUT.webm
# mp4
ffmpeg -i IN -acodec aac -strict experimental -ac 2 -ab 128k -vcodec libx264 -vpre slow -f mp4 -crf 22 -s 640x360 OUT.mp4
# ogg (if you want to support older Firefox)
ffmpeg2theora IN -o OUT.ogv -x 640 -y 360 --videoquality 5 --audioquality 0 --frontend
// @flow
import React from 'react';
const starEmoji = '⭐';
type StarPropsShape = {| score: number |};
const Star = ({ score }: StarPropsShape) => (
<span className="score-star">
{starEmoji.repeat(Math.floor(score))}
@pyldin601
pyldin601 / swapon.sh
Last active July 29, 2017 09:39
Enable SWAP file on VPS
#!/bin/sh
cd /var
touch swap.img
chmod 600 swap.img
dd if=/dev/zero of=/var/swap.img bs=1024k count=1000 # 1000MB
mkswap /var/swap.img
swapon /var/swap.img
echo "/var/swap.img none swap sw 0 0" >> /etc/fstab
@pyldin601
pyldin601 / gist:92028758d12ffcff86e3bdfe063ed0f0
Created July 25, 2017 10:53 — forked from stuart11n/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@pyldin601
pyldin601 / common.kt
Last active March 6, 2017 09:34
String Parser 2
fun <T> List<T>.headTail(): Pair<T, List<T>> = Pair(first(), drop(1))
typealias Result = List<Pair<String, Int>>
fun iterString(rest: List<Char>, stringAcc: String, numberAcc: String, acc: Result): Result {
if (rest.isEmpty()) {
throw IllegalStateException()
}
val (head, tail) = rest.headTail()
if (head.isLetter()) {
@pyldin601
pyldin601 / parser.kt
Created February 28, 2017 09:39
String parser
enum class State { STRING, DIGIT }
fun stringToStructure(string: String): List<Pair<String, Int>> {
val result: MutableList<Pair<String, Int>> = mutableListOf()
var previousState = State.STRING
var stringAcc = ""
var numberAcc = ""
fun saveAccumulators() {
@RequestMapping(method = RequestMethod.GET, value = "/{video:.+}")
public StreamingResponseBody stream(@PathVariable String video)
throws FileNotFoundException {
File videoFile = videos.get(video);
final InputStream videoFileStream = new FileInputStream(videoFile);
return (os) -> {
readAndWrite(videoFileStream, os);
};
}