Skip to content

Instantly share code, notes, and snippets.

View motorcityadam's full-sized avatar
🤖
Industrial Roboticist

Adam Cook motorcityadam

🤖
Industrial Roboticist
View GitHub Profile
@motorcityadam
motorcityadam / u32_f32.c
Created July 22, 2023 03:41 — forked from rygorous/u32_f32.c
U32->F32 using SSE2 intrinsics.
// ---- Straightforward:
__m128i lo_int = _mm_and_si128(_mm_set1_epi32(0xffff), in); // low 16 bits of all vals
__m128i hi_int = _mm_srli_epi32(in, 16); // high 16 bits of all vals
__m128 lo_flt = _mm_cvtepi32_ps(lo_int); // exact (all 16 bit ints = machine numbers)
__m128 hi_flt = _mm_cvtepi32_ps(hi_int); // exact
__m128 hi_scl = _mm_mul_ps(hi_flt, _mm_set1_ps(65536.0f)); // exact (just exponent change)
__m128 result = _mm_add_ps(hi_scl, lo_flt); // this is the only step that rounds.
// same approach also works with FMA where available.
@motorcityadam
motorcityadam / preinstall.js
Created October 31, 2019 21:01
Preinstall script to fix npm proxy issues with Yarn and GitHub Package Registry
// Copyright (c) Alliedstrand Corporation. All rights reserved.
//
// Licensed under the MIT License.
'use strict';
/**
* @file Extract the GitHub Personal Access Token for GitHub Package Registry
* access.
*
<!-- For normal web browsers -->
<link rel="icon" type="image/x-icon" href="favicon.ico">
<!-- For older Chrome versions -->
<link rel="icon" type="image/png" sizes="32x32" href="favicon-32.png">
<!-- For iPad home screen -->
<link rel="icon" type="image/png" sizes="76x76" href="favicon-76.png">
<!-- For GoogleTV -->
<link rel="icon" type="image/png" sizes="96x96" href="favicon-96.png">
<!-- For iPhone Retina screens -->
<link rel="icon" type="image/png" sizes="120x120" href="favicon-120.png">
@motorcityadam
motorcityadam / introrx.md
Created June 13, 2016 13:36 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
server {
listen 80;
server_name localhost;
location / {
include uwsgi_params;
uwsgi_pass unix:/tmp/ap_admin.sock;
}
location /favicon.ico {
[uwsgi]
name = apadmin
chdir = /app/apadmin
home = /etc/python/virtual-envs/ap_admin
module = apadmin.wsgi:application
processes = 1
socket = /tmp/ap_admin.sock'
#!/bin/sh
{% for k, v in item.environment.iteritems() if k != 'name' %}
unset {{ k.upper() }}
{% endfor %}
echo "##################################"
echo "Completed deactivation of {{ item.environment.name }}."
#!/bin/sh
{% for k, v in item.environment.iteritems() if k != 'name' %}
export {{ k.upper() }}="{{ v }}"
{% endfor %}
echo "##################################"
echo "Completed activation of {{ item.environment.name }}."
---
python_major_minor_version: '3.4'
python_major_minor_patch_version: '3.4.3'
python_compressed_source_md5sum: '7d092d1bba6e17f0d9bd21b49e441dd5'
python_virtualenvs:
- name: 'virtualenv1'
requirements: '/app/virtualenv1_requirements.txt'
- name: 'virtualenv2'
requirements: '/app/virtualenv2_requirements.txt'
- name: Create activation scripts for the specified Python virtual environments
template:
src: virtualenv_postactivate.j2
dest: "{{ python_virtualenv_home_dir }}/{{ item.environment.name }}/bin/postactivate"
sudo: yes
sudo_user: "{{ python_user }}"
with_items: python_virtualenvs_variables
when: >
python_virtualenv_install and python_virtualenvs|length > 0 and
python_virtualenvs_variables and python_virtualenvs_variables|length > 0