Skip to content

Instantly share code, notes, and snippets.

View cfr's full-sized avatar
💭
👾

Stan Serebryakov cfr

💭
👾
View GitHub Profile
@cfr
cfr / config.zig
Last active December 3, 2023 18:27
pub const EntityType = enum { variable, array, object };
pub const Variable = struct { name: []const u8, value: []const u8 };
pub const Array = struct { name: []const u8, content: []const Variable };
pub const Object = struct { name: []const u8, fields: []const Variable };
pub const Entity = union(EntityType) { variable: Variable, array: Array, Object: Object };
@cfr
cfr / devert
Last active August 6, 2019 15:08
Fix vertical video
#!/usr/bin/env sh
# http://stackoverflow.com/a/30819570/187663
ffmpeg -i $1 -i $1 -filter_complex "[0:v]scale=-1:720[scaled_video];[1:v]scale=1280:720,boxblur=16[blur_image];[blur_image][scaled_video]overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2[outv]" -c:v libx264 -aspect 1280/720 -map [outv] -map 0:a -c:a copy $1.fixed.mp4
@cfr
cfr / CocoaLumberjack.swift
Last active May 9, 2018 06:46 — forked from stigi/CocoaLumberjack.swift
Swift 1.2 CocoaLumberjack wrapper
// Updated to Swift 1.2 and CocoaLumberjack 2.0.0-rc by Stan Serebryakov on 2015-02-16
import Foundation
extension DDLog {
private struct State {
static var logLevel: DDLogLevel = .Error
static var logAsync: Bool = true
}
@cfr
cfr / db-upload-chunk-backup.py
Created October 25, 2017 11:31
Script to backup large file to dropbox
#!/usr/bin/env python
import dropbox
import os
import time
file_path = "/opt/backups/backup.tar.gz"
dest_path = "/Apps/backup/"
dbx = dropbox.Dropbox("<app-token>")
dest_today_path = dest_path + time.strftime("%Y-%m-%d") + ".tgz"
# Just copy paste if you want more chests. The percentages for chests must add up to 100!
config:
enabled: true
modes:
chests: true
items: false
chests:
chest1:
items: 5*64;5*64;5*64;5*64;262*64;278*1;5*64%30
percentage: 5
{-# LANGUAGE OverloadedStrings, RecordWildCards #-}
import Data.Text hiding (filter, unwords)
import Pipes
import Data.IORef
import Data.Maybe
import Data.Time (UTCTime(..), getCurrentTime)
import qualified Data.Map.Strict as M
// cfr.pw
#include "JG.h"
#include "DungeonGenerator.h"
ADungeonGenerator::ADungeonGenerator() {
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
RootComponent = CreateDefaultSubobject<USceneComponent>("SceneRoot");
use std::hashmap::HashMap;
fn main() {
// create a hashmap
let mut hm = HashMap::new();
hm.insert(~"foo", 10);
hm.insert(~"bar", 23);
hm.insert(~"baz", 99);
hm.insert(~"meh", 2);
hm.insert(~"muh", -13);
@cfr
cfr / generic-print.c11.c
Last active December 20, 2015 01:59
C11 _Generic print
#define printf_dec_format(x) _Generic((x), \
char: "%c", \
signed char: "%hhd", \
unsigned char: "%hhu", \
signed short: "%hd", \
unsigned short: "%hu", \
signed int: "%d", \
unsigned int: "%u", \
long int: "%ld", \
unsigned long int: "%lu", \
@cfr
cfr / sequence.m
Last active December 19, 2015 15:59
sequence
typedef void (^OpCompletionEither)(BOOL success);
- (void)sequence:(NSArray *)selectors
withFinalBlock:(OpCompletionEither)block {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
__block OpCompletionEither _block = block;
SEL selector = NSSelectorFromString(selectors[0]);
if (selectors.count == 1)
// last request, perform reply block