Skip to content

Instantly share code, notes, and snippets.

@ghedo
ghedo / sound_playback.c
Last active March 2, 2024 08:47
Simple sound playback using ALSA API and libasound
/*
* Simple sound playback using ALSA API and libasound.
*
* Compile:
* $ cc -o play sound_playback.c -lasound
*
* Usage:
* $ ./play <sample_rate> <channels> <seconds> < <file>
*
* Examples:
@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active April 23, 2024 19:14
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@dfwarden
dfwarden / gapps-groupssettings-adminexample.py
Created April 30, 2013 14:14
Example of administrative OAuth 2.0 access to Google Group Settings API.
import httplib2
import oauth2client.client
import pprint
from apiclient.discovery import build
serviceacct_email = "<your service account email address>"
f = file('groupssettings-privatekey.p12', 'rb')
client_key = f.read()
f.close()
@cansadadeserfeliz
cansadadeserfeliz / tests.py
Last active December 28, 2022 09:20
Mock/replace timezone.now() with a custom date in Django unittes
#! /usr/bin/env python
# -*- coding: utf-8 -*-
import datetime
from mock import patch
from django.test import TestCase
from django.utils import timezone
class DatesTestCase(TestCase):
@itsmemattchung
itsmemattchung / Makefile
Last active December 16, 2019 09:30
Makefile example for aws lambda
PROJECT = sample-python-app
FUNCTION = $(PROJECT)
REGION = us-east-1
.phony: clean
clean:
rm -f -r $(FUNCTION)*
rm -f -r site-packages
@markerikson
markerikson / ReactControlledInputWithState.jsx
Created August 2, 2017 02:53
React controlled input with internal state example
class ControlledInputWithInternalState extends Component {
constructor(props) {
super(props);
this.state = {
isValid : true,
value : props.value
};
}
@artizirk
artizirk / 0README.md
Last active September 26, 2022 01:46
Apple macOS Catalina under Linux KVM with GVT-g Intel GPU passthrough notes
@khalidx
khalidx / node-typescript-esm.md
Last active April 22, 2024 15:40
A Node + TypeScript + ts-node + ESM experience that works.

The experience of using Node.JS with TypeScript, ts-node, and ESM is horrible.

There are countless guides of how to integrate them, but none of them seem to work.

Here's what worked for me.

Just add the following files and run npm run dev. You'll be good to go!

package.json