Skip to content

Instantly share code, notes, and snippets.

View offero's full-sized avatar

Chris offero

View GitHub Profile
@mfellner
mfellner / graphql.ts
Created July 8, 2019 20:42
Using Apollo Server in Next.js 9 with API route in pages/api/graphql.ts
import { ApolloServer, gql } from 'apollo-server-micro';
const typeDefs = gql`
type Query {
sayHello: String
}
`;
const resolvers = {
Query: {
@matthiassb
matthiassb / dns-sync.sh
Last active August 24, 2024 09:43
Init.d script for keeping WSL resolv.conf in-sync with Windows
#! /bin/bash
### BEGIN INIT INFO
# Provides: dns-sync
# Required-Start:
# Required-Stop:
# Default-Start: S
# Default-Stop:
# Short-Description: Synchronizes /etc/resolv.conf in WLS with Windows DNS - Matthias Brooks
### END INIT INFO
@ephys
ephys / FormattedMessageTag.js
Last active June 2, 2018 13:24
An extension to React-Intl to format messages that contain XML
// @flow
// V2 on NPM fixes notes below
// https://github.com/Ephys/react-intl-formatted-xml-message
// NOTE: Currently with this implementation, XML present in the variables you pass to FormattedMessageTag will also be converted to react components.
// I'm working on a way to fix this issue. Right now I think that'll mean re-implementing FormattedMessage so the XML parsing part skips {variable} tags
// TODO:
// Replace all object or string values with placeholder tags
@miglen
miglen / osx_wifi_strenght_command_line.sh
Created January 14, 2018 18:46
Mac OS X Wifi Signal strength meter command line
#!/bin/bash
# Simple command to display the wireless strenght signal
#
clear
while x=1
do /System/Library/PrivateFrameworks/Apple*.framework/Versions/Current/Resources/airport -I \
| grep CtlRSSI \
| sed -e 's/^.*://g' \
| xargs -I SIGNAL printf "\rWifi dBm: SIGNAL"
sleep 0.5
@asroy
asroy / Debugging Mixed Python C++ code in Visual Studio Code
Last active August 25, 2022 17:43
Debugging Mixed Python/C++ code in Visual Studio Code
I've tested it on Fedora 23 and Ubuntu 16.04. I'm using gcc-5.3.1, python-3.4, VS Code-1.14.0
You can debug mixed Python/C++ in the same GUI. It also works for MPI applications. You can switch between the debuggers and corresponding call stacks.
1. Packages needed
1) Visual Studio Code
2) Extensions for VS Code:
"Python" from Don Jayamanne (I'm using 0.6.7)
This allows VS Code act as the front end to debug python.
This gives VS Code ability to attach to a python script that uses module "ptvsd".
@oscarmorrison
oscarmorrison / getParamsFromSearchURL.js
Last active July 6, 2017 20:35
Get params from search url
const getParamsFromSearchURL = url => url.slice(1).split('&').reduce((params, pairs) => {
const [key, value] = pairs.split('=');
key && value && (params[key] = getValue(value));
return params;
}, {});
// this parses foo=true -> make true a bool, not a string
const getValue = value => {
value = decodeURIComponent(value);
try {
@jgautheron
jgautheron / errorHandler.js
Created May 10, 2017 14:52
Send client errors to the server
import ReactUpdates from 'react-dom/lib/ReactUpdates'
import ReactDefaultBatchingStrategy from 'react-dom/lib/ReactDefaultBatchingStrategy'
import 'isomorphic-fetch'
const logError = (err, extra = {}) => {
fetch('/logger', {
method: 'POST',
credentials: 'same-origin',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
@matthewjberger
matthewjberger / instructions.md
Last active May 10, 2025 01:24
Install a nerd font on ubuntu

1.) Download a Nerd Font

2.) Unzip and copy to ~/.fonts

3.) Run the command fc-cache -fv to manually rebuild the font cache

@orenitamar
orenitamar / Dockerfile
Last active March 22, 2024 05:13
Installing numpy, scipy, pandas and matplotlib in Alpine (Docker)
# Below are the dependencies required for installing the common combination of numpy, scipy, pandas and matplotlib
# in an Alpine based Docker image.
FROM alpine:3.4
RUN echo "http://dl-8.alpinelinux.org/alpine/edge/community" >> /etc/apk/repositories
RUN apk --no-cache --update-cache add gcc gfortran python python-dev py-pip build-base wget freetype-dev libpng-dev openblas-dev
RUN ln -s /usr/include/locale.h /usr/include/xlocale.h
RUN pip install numpy scipy pandas matplotlib
@endeepak
endeepak / influxdb_measurement_series_count_per_measurement.sh
Created January 30, 2017 14:05
Influxdb : Print cardinality / series count per measurement
#!/usr/bin/env bash
if [ "$#" -ne 1 ]
then
echo "Usage: $0 <db_name>"
exit 1
fi
db_name=$1