Skip to content

Instantly share code, notes, and snippets.

@abemedia
abemedia / workflow.yml
Created March 21, 2023 03:08
GitHub Actions Go Cache
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version-file: go.mod
cache: false
@abemedia
abemedia / equal_test.go
Created March 21, 2023 01:48
Compare equal structs with different field order
package main_test
import (
"reflect"
"testing"
"github.com/google/go-cmp/cmp"
)
func TestEqual(t *testing.T) {
@abemedia
abemedia / codesign.yml
Created April 3, 2021 15:35
github actions macos codesign
- name: Setup codesign
env:
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
KEYCHAIN_NAME: hello
KEYCHAIN_PWD: hello
run: |
echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
security create-keychain -p $KEYCHAIN_PWD $KEYCHAIN_NAME
security default-keychain -s $KEYCHAIN_NAME
package nslog
/*
#cgo CFLAGS: -x objective-c
#cgo LDFLAGS: -framework Foundation
#import <Foundation/Foundation.h>
void Log(const char *text) {
NSString *nss = [NSString stringWithUTF8String:text];
NSLog(@"%@", nss);
}
@abemedia
abemedia / toggle-touchpad.sh
Created April 19, 2020 02:42
Bash script to toggle touchpad on/off
#!/bin/bash
read TPdevice <<< $( xinput | sed -nre '/TouchPad/s/.*id=([0-9]*).*/\1/p' )
state=$( xinput list-props "$TPdevice" | grep "Device Enabled" | grep -o "[01]$" )
if [ "$state" -eq '1' ];then
xinput --disable "$TPdevice"
notify-send Touchpad Disabled
else
xinput --enable "$TPdevice"
@abemedia
abemedia / api-client.js
Created April 19, 2020 00:26
fetch api client
class APIError extends Error {
constructor(response) {
super(response.message);
this.name = 'APIError';
this.code = `errors.${response.code}`;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, this.constructor);
} else {
this.stack = new Error().stack;
}
"*":
"atom-beautify":
general:
_analyticsUserId: "b4c23a8d-a7fc-4786-b02d-51655c7cdbe5"
js:
beautify_on_save: true
default_beautifier: "ESLint Fixer"
vue:
break_chained_methods: true
default_beautifier: "ESLint Fixer"
@abemedia
abemedia / regex
Created November 1, 2015 04:46
Simple regex to extract Google Plus ID from a user submitted URL
/(?:https?:\/\/)?(?:plus\.google\.com\/)?(?:.\/.\/*)?([^\/\s]*)/i
@abemedia
abemedia / regex
Created November 1, 2015 04:46
Simple regex to extract Google Plus ID from a user submitted URL
/(?:https?:\/\/)?(?:plus\.google\.com\/)?(?:.\/.\/*)?([^\/\s]*)/i
@abemedia
abemedia / google-cse-bootstrap.less
Created October 27, 2015 05:06
Google Custom Search Bootstrap Theme
/* Google Custom Search - Bootstrap Theme
-------------------------------------------------- */
@gs-title-size: @font-size-h4;
@gs-url-color: @brand-success;
@gs-thumbnail-size: 90px;
/* Search Form