Skip to content

Instantly share code, notes, and snippets.

@vshymanskyy
vshymanskyy / TypedBase64.js
Created September 25, 2017 12:33
TypedArray to base64 and back
input = new Float64Array([1,2,3,4])
encoded = Buffer.from(input.buffer).toString('base64')
buff = Buffer.from(encoded, 'base64');
decoded = new Float64Array(Uint8Array.from(buff).buffer)
@craffel
craffel / popcount_array.pyx
Last active October 11, 2022 20:48 — forked from aldro61/popcount_array.pyx
Popcount of a numpy array of integers of any dtype
"""
Functions for computing the population count (aka Hamming weight) of an array
in-place using the built-in popcount routine.
Works with any integer datatype 64 bit-width or smaller.
Compile with gcc flag -mpopcnt
Adapted from
https://gist.github.com/aldro61/f604a3fa79b3dec5436a by Alexandre Drouin
"""
import numpy as np
cimport numpy as np
@aldro61
aldro61 / popcount_array.pyx
Last active October 2, 2023 13:07
Popcount of a numpy array of 32-bit integers
"""
Compile with gcc flag -mpopcnt
"""
import numpy as np
cimport numpy as np
cimport cython
from libc.stdint cimport uint32_t, uint8_t
cdef extern int __builtin_popcount(unsigned int) nogil
@bigfive
bigfive / active_admin_helper.rb
Last active November 15, 2018 21:33
Active admin reskin
module ActiveAdminHelper
def admin_arbre_context
@admin_arbre_context ||= Arbre::Context.new(assigns, self)
end
def default_renderer
case controller.send(:resource_class).name
when "ActiveAdmin::Page"
"page"
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active March 1, 2026 01:02
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@bbtfr
bbtfr / test.yml.erb
Created December 6, 2012 06:47
Use yaml with erb
key: >
<%= case name
when 'A' # critical
1
when 'B' # warining
2
else # ok
0
end %>
@mrpatrick
mrpatrick / ga_js_demo_fixed.html
Created May 10, 2012 21:04
Google Analytics Easy Dashboard Javascript Library demo
<!DOCTYPE>
<html>
<head><title>GA Dash Demo</title></head>
<body onload="chart1.render();" >
<!-- Add Google Analytics authorization button -->
<button id="authorize-button" style="visibility: hidden">
Authorize Analytics</button>
<!-- Div element where the Line Chart will be placed -->