Skip to content

Instantly share code, notes, and snippets.

View bk138's full-sized avatar
🐿️
creating

Christian Beier bk138

🐿️
creating
View GitHub Profile
@cjus
cjus / jsonval.sh
Created June 26, 2011 17:42
Extract a JSON value from a BASH script
#!/bin/bash
function jsonval {
temp=`echo $json | sed 's/\\\\\//\//g' | sed 's/[{}]//g' | awk -v k="text" '{n=split($0,a,","); for (i=1; i<=n; i++) print a[i]}' | sed 's/\"\:\"/\|/g' | sed 's/[\,]/ /g' | sed 's/\"//g' | grep -w $prop`
echo ${temp##*|}
}
json=`curl -s -X GET http://twitter.com/users/show/$1.json`
prop='profile_image_url'
picurl=`jsonval`
@andrewharvey
andrewharvey / logrotatecat
Created December 15, 2011 09:34
cat's a bunch of log rotate log files in correct order
#!/bin/bash
# using,
#
# ./logrotatecat access.log
#
# inside a directory of log rotate logs in a form like
#
# access.log
# access.log.1
@EmielM
EmielM / uiwebview-tweaks.m
Created May 8, 2014 18:31
UIWebview enhancement hacks
// Continuously changing GIST of UIWebView 'tweaks' I use. Might be useful to others,
// hope Google finds this. Some of these already passed Review, but one never knows ;).
// Happy coding!
- (void)ScrollView_setContentOffset:(CGPoint)offset {
// Prevent superfluous scrolling animations (eg when toggling keyboard) by completely disabling scrolling. We achieve scrolling through inner scroll views (overflowing html elements).
}
- (id)WebBrowserView_inputAccessoryView {
// Make the keyboard accessory view (next/prev,submit buttons) optional, it really takes up to much screen estate in a normal app.
@mildmojo
mildmojo / rotate_desktop.sh
Created June 18, 2014 06:47
Script to rotate the screen and touch devices on modern Linux desktops. Great for convertible laptops.
#!/bin/bash
#
# rotate_desktop.sh
#
# Rotates modern Linux desktop screen and input devices to match. Handy for
# convertible notebooks. Call this script from panel launchers, keyboard
# shortcuts, or touch gesture bindings (xSwipe, touchegg, etc.).
#
# Using transformation matrix bits taken from:
# https://wiki.ubuntu.com/X/InputCoordinateTransformation
@staltz
staltz / introrx.md
Last active May 6, 2024 01:44
The introduction to Reactive Programming you've been missing
@steipete
steipete / PSPDFEnvironment.m
Last active March 5, 2024 09:15
Example for DISPATCH_SOURCE_TYPE_MEMORYPRESSURE (Mac only, since 10.9) ... Since we share code between iOS and mac, I'm trying to be a good system citizen and reimplement the equivalent of UIApplicationDidReceiveMemoryWarningNotification on the Mac.
NSString *const PSPDFApplicationDidReceiveMemoryWarningNotification = @"PSPDFApplicationDidReceiveMemoryWarningNotification";
// Test with sudo memory_pressure -l critical. Don't forget to re-set afterwards!
__attribute__((constructor)) static void PSPDFInstallLowMemoryNotificationWarningMac(void) {
static dispatch_source_t source;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MEMORYPRESSURE, 0, DISPATCH_MEMORYPRESSURE_WARN|DISPATCH_MEMORYPRESSURE_CRITICAL, dispatch_get_main_queue());
dispatch_source_set_event_handler(source, ^{
dispatch_source_memorypressure_flags_t pressureLevel = dispatch_source_get_data(source);
@jokecamp
jokecamp / package.json
Last active July 6, 2020 13:50
Demo for Passport.js authentication in a Node.js Express application
{
"name": "securehelloworld",
"version": "1.0.0",
"description": "",
"main": "server.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
@samiraguiar
samiraguiar / MC Cheat Sheet
Last active April 13, 2024 10:22 — forked from maciakl/MC Cheat Sheet
Midnight Commander Cheat Sheet / Shortcuts
Note for newcomers:
In the shortcuts below, "C" stands for CTRL and "A" stands for "ALT". This is a convention
used in the Midnight Commander documentation and was kept here.
You can also use "ESC" instead of "ALT", which is useful on Macbooks.
Main View
---------------------------------------------------------------
- File/directory operations
@baines
baines / xkeyexample.c
Last active September 19, 2023 20:53
simple xlib key example
#include <stdio.h>
#include <locale.h>
#include <X11/Xlib.h>
#include <X11/keysym.h>
int main(void){
setlocale(LC_ALL, "");
Display* dpy = XOpenDisplay(NULL);
@MightyPork
MightyPork / utf8_encode.c
Last active February 28, 2024 08:07
C function to encode a Unicode code point as UTF-8 byte array
#include <stdint.h>
/**
* Encode a code point using UTF-8
*
* @author Ondřej Hruška <ondra@ondrovo.com>
* @license MIT
*
* @param out - output buffer (min 5 characters), will be 0-terminated
* @param utf - code point 0-0x10FFFF