Skip to content

Instantly share code, notes, and snippets.

@whatsnewsisyphus
whatsnewsisyphus / keybase.md
Created December 2, 2019 14:01
keybase.md

Keybase proof

I hereby claim:

  • I am whatsnewsisyphus on github.
  • I am freshsisyphus (https://keybase.io/freshsisyphus) on keybase.
  • I have a public key ASBPe-mPGHbtSaEZSEHPTRKqSw9d5Duwdjyisn8krC8eXQo

To claim this, I am signing this object:

import argparse
import imutils
import cv2
import os
for subdir, dirs, files in os.walk(r'/Volumes/Hamal/Aaaaargh/Stuff/'):
for file in files:
filepath = subdir + os.sep + file
if filepath.endswith(".mkv"):
@whatsnewsisyphus
whatsnewsisyphus / videoavg.cpp
Created September 19, 2019 06:27
Average videos
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;
namespace cv
{
using std::vector;
}
@whatsnewsisyphus
whatsnewsisyphus / relevanssi_groupby.md
Created February 18, 2017 14:36
Group by Post Type with Relevanssi

Do you mind exemplifying that? I'll submit the resulting code in a gist that you can share in the knowledgebase since this seems to be a frequent question in stackoverflow etc. I made some suggestions below.

Can you imagine a way where one could programmatically create the indexed array so that you don't have to declare the groups twice? For example, do the following. I'm going backwards from array keys to a string array because I don't know an easy way to create an array of arrays with keys from another string array, that would be a bit more semantically correct.

// Declare keyed arrays for hits sorting
$people_types_keyed = array( "faculty"=>array(), "staff"=>array(), "student"=>array() );
$academic_types_keyed = array ("courses"=>array(), "programs"=>array() );
$types = array_merge($academic_types_keyed, $people_types_keyed);
// insert array push code here
//merge hits back with php5 ... operator, much easier than redeclaring each key.
@whatsnewsisyphus
whatsnewsisyphus / uncode_custom_element_fields.php
Last active November 18, 2016 16:06
Adding a custom field
/**
* in elements_php in theme, under uncode_create_single_block
*/
case 'relationship':
$relationship = get_field('test_relationship', $block_data['id']);
if($relationship) {
foreach( $relationship as $r ) {
$r_link = get_permalink( $r->ID );
$r_title = get_the_title( $r->ID );
$inner_entry .= '<a href="'.$r_link.'">'.$r_title.'</a>'.$separator;
@whatsnewsisyphus
whatsnewsisyphus / emRemToPx.js
Created October 31, 2014 11:32
em / rem to px function
/**
* emRemToPx.js | @whatsnewsisyphus
* To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
* see CC0 Public Domain Dedication <http://creativecommons.org/publicdomain/zero/1.0/>.
*/
var emRemToPx = function( value, scope, suffix ) {
if (!scope || value.toLowerCase().indexOf("rem") >= 0) {
scope = 'body';
}
if (suffix === true) {