Skip to content

Instantly share code, notes, and snippets.

View bramus's full-sized avatar

Bramus bramus

View GitHub Profile
<?php
// @ref https://twitter.com/brendt_gd/status/1065534180266782721
$a = range(5, 8);
$b = range(13,16);
$c = range(1,3);
$current = range(1,16);
@bramus
bramus / isSunSup.php
Last active November 27, 2018 13:23
PHP: Is The Sun Up (standalone version)?
<?php
function sunIsUp(\DateTime $when, $lat, $lon): bool {
$whenTimestamp = $when->getTimestamp();
$sunriseTimestamp = date_sunrise(
$whenTimestamp,
SUNFUNCS_RET_TIMESTAMP,
$lat,
$lon
@bramus
bramus / gist:6f0de89d49d2f2ffc07e7662613a6a68
Created August 21, 2018 12:20
Download entire website
# wget
wget -m -p -E -k www.domain.tld
# httrack
httrack http://www.domain.tld +www.domain.tld/* --path './httrack' --verbose
---
format_version: 1.1.0
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git
trigger_map:
- push_branch: "*"
workflow: tests
workflows:
_tests_setup:
steps:
- activate-ssh-key: {}
@bramus
bramus / fix.md
Last active May 20, 2018 19:47
Fixing the XCode 9.x Simulator 3D/Map Performance issue

Got a slow/unresponsive Simulator with XCode 9.x?

You're most likely using some kind of 3D or Native Maps in your App then, no? Awaiting XCode 9.1 (which contains a fix) here's a workaround which replaces the bundled OpenGLES.framework with the version from XCode 9.0 beta 3.

Please do note …

⚠️ Installing frameworks/binaries from unfamiliar/untrusted resources always involves some risk. I can only say that I’ve been using the linked version without any issues. Your mileage may vary.

Instructions

{
"canvas": {
"width": 1200,
"height": 650
},
"backgrounds": [
{
"url": "https://cdn.zender.tv/live/player/thepassion/carddesigns/backgrounds/big/01.png",
"thumbnail_url": "https://cdn.zender.tv/live/player/thepassion/carddesigns/backgrounds/small/01.png",
"colors": {
@bramus
bramus / StreamResponseFactory.php
Created January 6, 2017 20:19
Glide StreamResponseFactory
<?php
use League\Flysystem\FilesystemInterface;
class StreamResponseFactory implements \League\Glide\Responses\ResponseFactoryInterface {
public function create(FilesystemInterface $cache, $path) {
return $cache->readStream($path);
}
}
# ssh keys
# `brew install reattach-to-user-namespace
set-option -g default-command "reattach-to-user-namespace -l bash"
# mouse scrolling
set-option -g mouse on
# make scrolling with wheels work
# @ref http://stackoverflow.com/a/33461197/2076595
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"
// key = value
array_reduce($input, function ($carry, $item) {
$carry[$item['x']] = $item['y'];
return $carry;
}, []);
// key = value, from array with keys
array_reduce(array_keys($input), function($carry, $key) use ($input) {
$carry[] = $input[$key]['x'];
return $carry;