Skip to content

Instantly share code, notes, and snippets.

View loderunner's full-sized avatar
👨‍💻
𝚌𝚘𝚍𝚎 𝚕𝚒𝚏𝚎

Charles Francoise loderunner

👨‍💻
𝚌𝚘𝚍𝚎 𝚕𝚒𝚏𝚎
View GitHub Profile
CREATE DEFINER = CURRENT_USER TRIGGER `task`.`user_AFTER_INSERT`
AFTER INSERT ON `user` FOR EACH ROW
INSERT INTO `task`.`event` SET `type` = 'create',
`user_id` = NEW.`id`,
`timestamp` = NULL,
`created_at` = NULL,
`modified_at` = NULL;
CREATE DEFINER = CURRENT_USER TRIGGER `task`.`user_AFTER_UPDATE`
AFTER UPDATE ON `user` FOR EACH ROW
QApplication qapp(argc, argv);
{
QNetworkConfigurationManager manager;
QList<QNetworkConfiguration> configs(manager.allConfigurations());
QNetworkConfiguration config;
foreach (config, configs)
{
NSString* type;
switch (config.type())
// GetHostName.c
//
// Prints current host's name in localized, human-readable format to stdout
//
// Compile using:
// cc -framework SystemConfiguration -framework CoreFoundation -o GetHostName GetHostName.c
//
#include <SystemConfiguration/SystemConfiguration.h>
@loderunner
loderunner / change_install_path.sh
Created February 12, 2015 17:32
Change ids and install paths relative to @executable_path
USER_PREFIX=/Users
LOADER_PATH_PREFIX=@loader_path
for f in *.dylib; do
old_install_path="$(otool -D "$f" | sed '2q;d' | grep -E "$USER_PREFIX|$LOADER_PATH_PREFIX")"
if [ -n "$old_install_path" ]; then
new_install_path="$(sed -E "s%($USER_PREFIX|$LOADER_PATH_PREFIX).*%@executable_path/../Frameworks/%" <<< "$old_install_path")""$(basename "$old_install_path")"
echo "$old_install_path -> $new_install_path"
install_name_tool -id "$new_install_path" "$f"
fi
for old_install_path in $(otool -L "$f" | grep -E "$USER_PREFIX|$LOADER_PATH_PREFIX" | awk '{print $1}'); do
from numpy.polynomial.polynomial import polyval
from scipy.optimize import newton
from random import random
def poly(coeffs):
def polyfunc(x):
return polyval(x, coeffs)
return polyfunc
# Polynomial: coeffs[0]*x^0 + coeffs[1]*x^1 + coeffs[2]*x^2 + ...
setInterval(function(){ var d = $('#thebutton-s-10s'); if (d.text() == '0') { var e = $('#thebutton-s-1s'); if (e.text() == '0') { $('.thebutton').click(); } } }, 100);
@loderunner
loderunner / 01-mac-profiling.md
Last active March 17, 2024 04:13
Profiling an application in Mac OS X

Profiling an application in Mac OS X

Finding which process to profile

If your system is running slowly, perhaps a process is using too much CPU time and won't let other processes run smoothly. To find out which processes are taking up a lot of CPU time, you can use Apple's Activity Monitor.

The CPU pane shows how processes are affecting CPU (processor) activity:

from mutagen.easyid3 import EasyID3 as Tag
from os import listdir
from re import sub
for f in listdir('.'):
if (f[-4:] == '.mp3'):
try:
tag = Tag(f)
except:
tag = Tag()
import gevent
import gevent.queue
import gevent.lock
from functools import partial
class JobQueue:
class Job:
def __init__(self, run=None, *args, **kwargs):
self.callback = kwargs.pop('dispatch_callback', None)
@loderunner
loderunner / osx-ld.md
Last active April 26, 2024 13:53
potential blog posts

ld – Wading through Mac OS X linker hell

Intro

Friend: I tried looking at static linking in Mac OS X and it seems nearly impossible. Take a look at this http://stackoverflow.com/a/3801032

Me: I have no idea what that -static flag does, but I'm pretty sure that's not how you link to a library. Let me RTFM a bit.

Minutes later...