Skip to content

Instantly share code, notes, and snippets.

View TrevorJTClarke's full-sized avatar
🙈

Trevor Clarke TrevorJTClarke

🙈
View GitHub Profile
@TrevorJTClarke
TrevorJTClarke / BrowserDeviceInfo.js
Created September 1, 2015 17:52
A quick list of browsers and devices for use in testing. Chrome is used for all devices that need simulation.
var devices = [
{ name: 'Desktop - Huge', width: 2880, height: 1800, ratio: 2, type: 'desktop' },
{ name: 'Desktop - Extra Large', width: 1920, height: 1080, ratio: 1, type: 'desktop' },
{ name: 'Desktop - Large', width: 1440, height: 900, ratio: 1, type: 'desktop' },
{ name: 'Desktop - HiDPI', width: 1366, height: 768, ratio: 1, type: 'desktop' },
{ name: 'Desktop - MDPI', width: 1280, height: 800, ratio: 1, type: 'desktop' },
{ name: 'Laptop with HiDPI screen', width: 1440, height: 900, ratio: 2, type: 'desktop' },
{ name: 'Laptop with MDPI screen', width: 1280, height: 800, ratio: 1, type: 'desktop' },
{ name: 'Laptop with touch', width: 1280, height: 950, ratio: 1, type: 'desktop' },
{ name: 'Tablet - Portrait', width: 768, height: 1024, ratio: 1, type: 'tablet' },
// View Full documentation here: https://docs.amberdata.io/reference/tokens#get-historical-token-holders
axios({
method:'get',
url: 'https://web3api.io/api/v1/tokens/ETHEREUM_ADDRESS_HERE/holders/historical?timeFrame=30d',
headers: { 'x-api-key': 'YOUR_API_KEY_HERE' }
}).then(res => {
// res data example:
// {
// "metadata": {
// "columns": ["timestamp", "timestamp.holder*"]
@TrevorJTClarke
TrevorJTClarke / MediaFormat
Last active July 24, 2023 08:25
MediaFormat - A regex system for finding the media ID for each type of popular social site. Can identify YouTube, Vimeo, Spotify, and Soundcloud.
/**
* MediaFormat
* format and return only needed pieces of media from their public sources
* Author: Trevor Clarke
*/
function MediaFormat (){
// http://www.youtube.com/embed/m5yCOSHeYn4
var ytRegEx = /^(?:https?:\/\/)?(?:i\.|www\.|img\.)?(?:youtu\.be\/|youtube\.com\/|ytimg\.com\/)(?:embed\/|v\/|vi\/|vi_webp\/|watch\?v=|watch\?.+&v=)((\w|-){11})(?:\S+)?$/;
// http://vimeo.com/3116167, https://player.vimeo.com/video/50489180, http://vimeo.com/channels/3116167, http://vimeo.com/channels/staffpicks/113544877
var vmRegEx = /https?:\/\/(?:vimeo\.com\/|player\.vimeo\.com\/)(?:video\/|(?:channels\/staffpicks\/|channels\/)|)((\w|-){7,9})/;
@TrevorJTClarke
TrevorJTClarke / Dynamic Angular Array Filter
Created May 8, 2015 17:54
Easier setup for deep object based filtering on an array in angularjs. Use: ng-repeat="item in someArray | objectFilter:filterReqObject"
// I wanted to be able to simply change an object with key/search values, so that any array item keys that match also check for those search values
// The returned data, is only data that meets all requirements inside of the filterObject
//
// Example filterObject:{
// names: "Trevor",
// countries: "USA"
// }
// Example Array: [{
// title: "People in USA"
// names: ["Trevor", "Steve"]
I contributed to the Semaphore Trusted Setup Multi-Party Ceremony.
The following are my contribution signatures:
Circuit: semaphore16
Contributor # 305
Hash: 20f76660 f3ecd008 f55ee086 6d669153
1a8e7553 eff89313 cc848e16 de95c191
172603a2 580ccf3a 9bc00185 d0dbf492
70092358 115c68b8 eb45d7e3 b8474a76
@TrevorJTClarke
TrevorJTClarke / ChromeEmulatorDeviceList.js
Created August 18, 2015 17:34
Chrome Emulator Device List and Properties
var emulatorDeviceList = [
{ name: 'Amazon Kindle Fire HDX', width: 2560, height: 1600, ratio: 2 },
{ name: 'Apple iPad', width: 1024, height: 768, ratio: 2 },
{ name: 'Apple iPad Mini', width: 1024, height: 768, ratio: 1 },
{ name: 'Apple iPhone 4', width: 320, height: 480, ratio: 2 },
{ name: 'Apple iPhone 5', width: 320, height: 568, ratio: 2 },
{ name: 'Apple iPhone 6', width: 375, height: 667, ratio: 2 },
{ name: 'Apple iPhone 6 Plus', width: 414, height: 736, ratio: 3 },
{ name: 'BlackBerry PlayBook', width: 1024, height: 600, ratio: 1 },
{ name: 'BlackBerry Z30', width: 360, height: 640, ratio: 2 },
set -e
NETWORK=mainnet
OWNER=sputnik-dao.$NETWORK
COUNCIL_ACC=CHANGE_ME.near
export DAO_NAME=hack #mynewdao.sputnikv2.testnet
##Change NODE_ENV between mainnet, testnet and betanet
export NODE_ENV=mainnet
const WebSocket = require('ws');
const ws = new WebSocket('wss://ws.web3api.io', {headers: {x-api-key:'<api_key>'}});
// Events:
// addLiquidity 0x4d49e87d
// addLiquidityIbETHv2AlphaOptimal(uint256,uint256,uint256,address,uint256) 0xe52bc129
// addLiquidityETHAlphaOptimal(uint256,uint256,address,uint256) 0xb057e457
// addLiquidity(uint256) 0x51c6590a
ws.on('open', () => {
@TrevorJTClarke
TrevorJTClarke / nodejs session with near protocol ed25519
Last active January 25, 2021 09:12
Expressjs middleware for handling authentication based on recent signed messages
import axios from 'axios'
import nacl from 'tweetnacl'
import { utils } from 'near-api-js'
import getNearConfig from './config'
require('dotenv').config()
// string to uint array
// REF: https://coolaj86.com/articles/unicode-string-to-a-utf-8-typed-array-buffer-in-javascript/
function unicodeStringToTypedArray(s) {
const escstr = encodeURIComponent(s)
const socket = new WebSocket(`wss://ws.web3api.io?x-api-key=${YOUR_API_KEY_HERE}`)
socket.addEventListener('open', event => {
console.log('Connection opened - ', event)
})
// Closed Connection
socket.addEventListener('close', event => {
console.log('Connection closed - ', event.data)
})