Skip to content

Instantly share code, notes, and snippets.

// A shitty little script to find duplicate files and merge things back together again
// Used after a reinstall of google drive sync caused a bunch of duplicate files to be created on google drive
// and needed to clean things up again to reclaim some space, as there was no way to do this automatically.
package dupes
import (
"crypto/sha256"
"errors"
"fmt"
@Psykar
Psykar / recipes.py
Created March 23, 2021 08:55
Pick two recipes at random from a weighted csv
from random import choices
import csv
import string
def pick():
with open("recipes.csv") as f:
r = csv.reader(f)
data = list(r)
recipes, weights = zip(*data)
@Psykar
Psykar / fs_test.go
Last active March 4, 2021 08:46
A quick dirty mock implementation of an fs.FS
package testing
import (
"fmt"
"io/fs"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/mock"
import requests
headers = dict(Authorization="Bearer <redacted>")
resp = requests.get("https://api.up.com.au/api/v1/accounts", headers=headers)
for account in resp.json()['data']:
print(account['attributes']['displayName'], account['attributes']['balance']['value'])
BR2_arm=y
BR2_cortex_a9=y
BR2_ARM_ENABLE_NEON=y
BR2_ARM_ENABLE_VFP=y
BR2_PACKAGE_HOST_LINUX_HEADERS_CUSTOM_4_19=y
BR2_TARGET_GENERIC_GETTY_PORT="ttyPS0"
BR2_ROOTFS_POST_IMAGE_SCRIPT="board/zynq/post-image.sh"
BR2_LINUX_KERNEL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL=y
BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION="$(call github,Xilinx,linux-xlnx,xilinx-v2019.1)/linux-xilinx-v2019.1.tar.gz"
U-Boot SPL 2016.09 (Nov 01 2017 - 12:10:27)
Trying to boot from MMC1
MMC Device 1 not found
** Bad device mmc 1 **
Using default environment
reading u-boot.img
reading u-boot.img
#!/usr/bin/env python
import subprocess
import sys
import os
sys.path.append(os.environ['MODULESHOME']+"/init")
from python import module
module('load skymaker')

Notes

  • This code handles any JS runtime error during rendering React components. Without this handling, once an error occurs, whole component tree is damaged and can't be used at all. With this handling, nothing will be rendered in production environment (error span in dev env.) + in production the error is logged to Sentry (if you are not using it just delete related code)
  • This is basicaly a workaround for proposed feature in React core - described in Issue: facebook/react#2461
  • Works for all variants of Component creation - React.createClass, extending React.Component and also stateless functional components.
  • To get this work, just put this snippet into your entry js file. Then it will work in whole application.
  • Also supporting React Hot Reload!
  • If you find this useful, please retweet https://twitter.com/Aldredcz/status/744650159942995968 :)

Ideas

  • specify custom error renderer (global / per component, e.g. by implementing method renderOnError() in a comp
{
"name": "XXX",
"version": "0.0.1",
"dependencies": {
"abbrev": {
"version": "1.0.7",
"from": "abbrev@>=1.0.0 <2.0.0",
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.7.tgz"
},
"absolute-path": {
@Psykar
Psykar / PKGBUILD
Created April 15, 2015 04:59
graffle2svg-svn PKGBUILD
# Maintainer: fmjrey
pkgname=graffle2svg-svn
pkgver=29
pkgrel=1
pkgdesc="Basic converter from omnigraffle (.graffle file) to svg"
arch=(any)
url="http://graffle2svg.googlecode.com"
license=('New BSD License')
depends=('python2')
provides=('graffle2svg')