Skip to content

Instantly share code, notes, and snippets.

@sukima
sukima / machine.js
Last active May 9, 2024 23:55
Generated by XState Viz: https://xstate.js.org/viz
const parseScannedData =
(context, event) => {
return (callback) => {
// This should be something that gets the json:
let { json } = {} // doSomethingAsync();
let isValid = Array.isArray(json);
if (!isValid) {
callback({ type: 'SCAN_ERROR' });
} else {
@sukima
sukima / adapters.application.js
Created August 16, 2018 16:31
Not serializing ember-data attrs
import DS from 'ember-data';
let id = 0;
function uniqId() {
id++;
return `${id}`;
}
export default DS.JSONAPIAdapter.extend({
ajax(url, method, { data }) {
lookupFactory(refName) {
// lookupMethod was moved to _lookupFactory in Ember 2.x+
// This is a well used API in the community but was never officially made
// public. Core team is in the process of making an official API for
// factories. Till then this is the only way to lookup factories from the
// registry. https://github.com/emberjs/rfcs/pull/150
const owner = getOwner(this);
const lookupFactory = owner._lookupFactory || owner.lookupFactory;
return lookupFactory.call(owner, refName);
}
@sukima
sukima / slack.vim
Last active May 9, 2024 23:54
Slack syntax highlighting for vim
" Vim syntax file
" Language: Slack
" Maintainer: Devin Weaver <suki@tritarget.org>
if exists("b:current_syntax")
finish
endif
syn case ignore
@sukima
sukima / httpPromise.js
Last active May 9, 2024 23:54
Turn TW5 httpRequest into a Promise API
function httpPromise(url, method, data) {
if (!data) {
data = method;
methos = 'GET';
}
return new Promise(function(resolve, reject) {
var http = $tw.utils.httpRequest({
url: url,
type: method,
data: data,
From 7c7e8615860eb40da0e95ae41d9f750079ac9eb4 Mon Sep 17 00:00:00 2001
From: Said <saidmoya12@gmail.com>
Date: Mon, 18 Apr 2016 14:45:03 -0500
Subject: [PATCH] Resize with device orientation changes
When a mobile device changes orientation it does not trigger the
`resize` event like a normal window resize would. This means on mobile
devices that changing the orientation does not cause the pannellum
canvas to resize. This commit resizes based on the `orientationchange`
event.
@sukima
sukima / AllPublicTiddlers.html.tid
Created March 24, 2016 10:34
Public/Private TiddlyWiki commands
title: $:/core/templates/allpublictiddlers.template.html
type: text/vnd.tiddlywiki-html
<!-- This template is provided for backwards compatibility with older versions of TiddlyWiki -->
<$set name="exportFilter" value="[!is[system]!tag[private]sort[title]]">
{{$:/core/templates/exporters/StaticRiver}}
</$set>
@kvedala
kvedala / main.go
Created May 27, 2022 21:03
Generating JWT Tokens with random secret key in golang
package main
import (
"crypto/hmac"
"crypto/sha512"
"fmt"
"log"
"math/rand"
"time"
@rxwx
rxwx / pulseversion.py
Created August 13, 2019 09:04
Pulse Secure Version Scanner
import requests
import sys
import re
HEADERS = {"User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:67.0) Gecko/20100101 Firefox/67.0"}
if len(sys.argv) != 2:
print " Usage: python pulseversion.py <target ip/domain>"
sys.exit(1)
@sukima
sukima / .gitignore
Last active May 9, 2024 23:52
Failing testdouble TypeScript issue
/node_modules
test.js