Skip to content

Instantly share code, notes, and snippets.

@Happy-Ferret
Happy-Ferret / values_pointers.go
Created April 19, 2018 06:09 — forked from josephspurrier/values_pointers.go
Golang - Asterisk and Ampersand Cheatsheet
/*
********************************************************************************
Golang - Asterisk and Ampersand Cheatsheet
********************************************************************************
Also available at: https://play.golang.org/p/lNpnS9j1ma
Allowed:
--------
p := Person{"Steve", 28} stores the value
@Happy-Ferret
Happy-Ferret / spectre.c
Created April 16, 2018 04:35 — forked from ErikAugust/spectre.c
Spectre example code
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#ifdef _MSC_VER
#include <intrin.h> /* for rdtscp and clflush */
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* for rdtscp and clflush */
#endif
@Happy-Ferret
Happy-Ferret / example.js
Created April 3, 2018 16:55 — forked from cosinusoidally/example.js
Garbage collector safe example embedding ChakraCore in Spidermonkey shell using js-ctypes
/*
Tested against release/1.4 branch of https://github.com/Microsoft/ChakraCore
commit: 6f4c890505a58bbf198035d4b93bf8a726033af3
The below program will work on x86_64 Linux. It demonstrates how to safely call
in to libChakraCore from Spidermonkey using js-ctypes. Because the ChakraCore
GC scans the stack for JsValueRefs we must allocate JsValueRefs on the C stack.
When I say C stack I mean in the memory region between the current stack
pointer and the initial value of the stack pointer when the program started.
Components.utils.import("resource://gre/modules/ctypes.jsm")
var liblog = ctypes.open('liblog.so');
var android_log = liblog.declare("__android_log_write",
ctypes.default_abi,
ctypes.int32_t,
ctypes.int32_t,
ctypes.char.ptr,
ctypes.char.ptr);
@Happy-Ferret
Happy-Ferret / add-jest-to-nwb.sh
Created March 20, 2018 12:37 — forked from rakannimer/add-jest-to-nwb.sh
Adding jest tests to nwb project
yarn add -D jest babel-jest babel-preset-es2015 babel-preset-react react-test-renderer
#Edit package.json adding the jest command :
"scripts": {
"build": "nwb build-react-component",
"clean": "nwb clean-module && npm clean-demo",
"start": "nwb serve-react-demo",
"test": "nwb test",
"test:coverage": "nwb test --coverage",
"test:watch": "nwb test --server",
"test:jest": "jest"
@Happy-Ferret
Happy-Ferret / palmBusWrapper
Created March 19, 2018 16:08 — forked from creationix/palmBusWrapper
bare-bones wrapper to convert PalmBus request API to node style callback API.
// Simple wrapper to make PamlBus requests.
function palmRequest(url, params, callback) {
var req = new PalmServiceBridge();
req.onservicecallback = function (result) {
var data;
try {
data = JSON.parse(result);
} catch (err) {
callback(err);
return;
@Happy-Ferret
Happy-Ferret / intro.md
Created March 14, 2018 11:52 — forked from paulirish/intro-overhead-of-performance.mark.md
Evaluating overhead of performance.mark()

A few conversations have circled around user-side structural profiling. For context, see React PR #7549: Show React events in the timeline when ReactPerf is active

One particular concern is the measurement overhead. This gist has a benchmarking script (measure.js) for evaluating overhead and initial results.

Results: performance.mark()

Runs about 0.65µs per mark() call. Naturally, that's ~= an overhead of 1ms for 1500 mark()s. image

@Happy-Ferret
Happy-Ferret / index.js
Created March 11, 2018 11:28 — forked from richardzcode/index.js
A custom home page that renders README.md in Docusaurus
const React = require('react');
const fs = require('fs-extra');
const path = require('path');
const readMetadata = require('../../server/readMetadata.js');
const CompLibrary = require('../../core/CompLibrary.js');
const MarkdownBlock = CompLibrary.MarkdownBlock; /* Used to read markdown */
const join = path.join;
const CWD = process.cwd();
@Happy-Ferret
Happy-Ferret / PhotoStream.cs
Created March 9, 2018 19:16 — forked from tobiasviehweger/PhotoStream.cs
Add image to shared iCloud photo stream programatically via COM on Windows
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace PhotoStreams
{