Skip to content

Instantly share code, notes, and snippets.

View sanmai's full-sized avatar

Alexey Kopytko sanmai

View GitHub Profile
@drupol
drupol / Finder.svg
Last active February 29, 2020 10:29
loophp/phptree + nikic/php-parser = <3
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@BackEndTea
BackEndTea / travis.yml
Created October 4, 2019 09:05
Allow composer to intall on nightly php
install:
- if [[ $TRAVIS_PHP_VERSION = nightly ]]; then export COMPOSER_FLAGS="--ignore-platform-reqs"; fi
- travis_retry composer update --prefer-dist $COMPOSER_FLAGS
@grago
grago / extension.swift
Created December 14, 2018 06:32
[Extension - Decoding JSON from your bundle] #ios #swift
extension Bundle {
func decode<T: Decodable>(_ type: T.Type, from filename: String) -> T {
guard let json = url(forResource: filename, withExtension: nil) else {
fatalError("Failed to locate \(filename) in app bundle.")
}
guard let jsonData = try? Data(contentsOf: json) else {
fatalError("Failed to load \(filename) from app bundle.")
}
@grago
grago / uiapplication.swift
Last active May 7, 2020 05:43
[Link to subscription and app settings] #ios
extension UIApplication {
class func openAppSettings() {
guard let url = URL(string: self.openSettingsURLString) else { return }
self.shared.open(url, options: [:], completionHandler: nil)
}
class func openSubscriptionManagement() {
guard let url = URL(string: "itms://apps.apple.com/account/subscriptions") else { return }
self.shared.open(url, options: [:], completionHandler: nil)
}
@JMWebDevelopment
JMWebDevelopment / WP REST API Controller Class
Created December 21, 2017 01:47
This is the base WP REST API Controller class
<?php class Sports_Bench_Team_REST_Controller extends WP_REST_Controller {
/**
* Register the routes for the objects of the controller.
*/
public function register_routes() {
$namespace = 'sportsbench';
$base = 'teams';
register_rest_route( $namespace, '/' . $base, array(
array(
@plashchynski
plashchynski / merge_dna_files.rb
Last active December 30, 2022 09:20
Tool to merge 23andme and Ancestory.com raw dna files
#!/usr/bin/ruby
#
# Usage:
# ruby ./merge_dna_files.rb file,file1,file2... > merged_file.txt
#
# Example:
# ruby ./merge_dna_files.rb AncestryDNA.txt genome_John_Doe_v4_Full_20170428065226.txt > merged_raw.txt
#
# Supports 23andMe, AncestryDNA, and Genes for Good 23andMe compatible file formats.
# The result will be in 23andMe file format.
@alcaeus
alcaeus / in_array_vs_isset_vs_array_key_exists.php
Created July 14, 2017 08:39
Performance comparision: in-array vs. isset vs. array_key_exists
<?php declare(strict_types = 1);
function testPerformance($name, Closure $closure, $runs = 1000000)
{
$start = microtime(true);
for (; $runs > 0; $runs--)
{
$closure();
}
$end = microtime(true);
@antirez
antirez / lmdb.tcl
Created April 28, 2017 15:40
LMDB -- First version of Redis written in Tcl
# LVDB - LLOOGG Memory DB
# Copyriht (C) 2009 Salvatore Sanfilippo <antirez@gmail.com>
# All Rights Reserved
# TODO
# - cron with cleanup of timedout clients, automatic dump
# - the dump should use array startsearch to write it line by line
# and may just use gets to read element by element and load the whole state.
# - 'help','stopserver','saveandstopserver','save','load','reset','keys' commands.
# - ttl with milliseconds resolution 'ttl a 1000'. Check ttl in dump!
@ViktorNova
ViktorNova / rotate-video.sh
Created August 8, 2016 21:33
Rotate a video with FFmpeg (100% lossless, and quick)
$INPUTVIDEO='input.mp4'
$OUTPUTVIDEO='output.mp4'
ffmpeg -i $INPUTVIDEO -metadata:s:v rotate="-90" -codec copy $OUTPUTVIDEO
<?php
<<<CONFIG
packages:
- "kriswallsmith/buzz: ^0.15.0"
- "symfony/console: ^3.2@dev"
CONFIG;
// Find you token on https://api.slack.com/docs/oauth-test-tokens
use Buzz\Message\Response;