Skip to content

Instantly share code, notes, and snippets.

View Kentzo's full-sized avatar
🤖

Ilya Kulakov Kentzo

🤖
View GitHub Profile
// Reads in a set of raw data files, and outputs smoothed files. (lots of libdispatch magic)
#define SIGMA (50)
#define CONST_A (1 / sqrt(2 * pi * (pow(SIGMA, 2))))
- (IBAction)smoothDataSets:(id)sender {
[openPanel beginSheetModalForWindow:self.window completionHandler:^(NSInteger ret){
if(ret == NSOKButton){
// Generate a gaussian weight
int len = 6 * SIGMA + 1;
double weight[len];
for(int i = 0; i < len; i++){
@Kentzo
Kentzo / AppKit.md
Created August 10, 2011 13:39
Hints for a Mac OS X Developer
@PsychoH13
PsychoH13 / PSYBlockTimer.h
Created December 7, 2009 06:19
Fire an NSTimer using a block as execution code.
/*
Copyright (c) 2009 Remy Demarest
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
@ShakataGaNai
ShakataGaNai / list_gcp_iprange.py
Last active January 21, 2020 15:56 — forked from n0531m/list_gcp_iprange.sh
Google Cloud Platform : ip address range
#!/usr/local/bin/python3.6
import dns.resolver
import re
def main():
v4 = []
v6 = []
v4, v6 = que('_cloud-netblocks.googleusercontent.com')
for o4 in v4:
print(o4)
@Catfish-Man
Catfish-Man / sethack.m
Created March 11, 2016 06:21
Demonstrating the trick of using stack-allocated mimics and sets for lookup tables instead of heap allocated keys and dictionaries
// Compile with clang -framework Foundation sethack.m
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
/*
CFHashBytes from http://www.opensource.apple.com/source/CF/CF-1153.18/CFUtilities.c
*/
#define ELF_STEP(B) T1 = (H << 4) + B; T2 = T1 & 0xF0000000; if (T2) T1 ^= (T2 >> 24); T1 &= (~T2); H = T1;
@purp
purp / README.md
Last active August 12, 2021 20:49
Debug Travis CI config locally using Docker

Debugging Travis CI locally using Docker

This assumes you've got docker-machine installed, running, and can do docker run

1. Get a debug instance running

    docker run --name travis-debug -dit quay.io/travisci/travis-ruby /sbin/init
    docker exec -it travis-debug bash -l
/**
* Several macros simplifying use of weak references to self inside blocks
* which goal is to reduce risk of retain cycles.
*
* Example:
* @code
@interface Example : NSObject{
int _i;
}
@sindresorhus
sindresorhus / gist:23c3e88c7685d77b95a8c380d08cbd45
Created March 4, 2017 17:35 — forked from vilhalmer/gist:3052f7e9e7f34b92a40f
NSVisualEffectView undocumentation
NSVisualEffectMaterial constants, and the undocumented materials they coorespond to in various modes:
+----------------------+-------+----------+------+---------+
| MATERIAL # | LIGHT | LIGHT EM | DARK | DARK EM |
+----------------------+-------+----------+------+---------+
| | | | | |
| 0 - Appearance Based | 3 | 3 | 5 | 5 |
| | | | | |
| 1 - Light | 3 | 3 | 3 | 3 |
| | | | | |
| 2 - Dark | 4 | 4 | 4 | 4 |
@0xced
0xced / NSRunningApplication+DockIcon.h
Created March 15, 2012 16:00
NSRunningApplication category to dynamically show and hide any running application icon in the Dock
//
// Created by Cédric Luthi on 2011-05-03
// Copyright 2011-2012 Cédric Luthi. All rights reserved.
//
#import <AppKit/AppKit.h>
@interface NSRunningApplication (DockIcon)
- (BOOL) setDockIconHidden_xcd:(BOOL)dockIconHidden;
@meagtan
meagtan / hensel.py
Last active June 18, 2023 23:29
p-adic numbers implemented in Python
# Finding roots of polynomials in p-adic integers using Hensel's lemma
from padic import *
from poly import *
def roots(p, poly):
'Yield all roots of polynomial in the given p-adic integers.'
for root in xrange(p):
try:
yield PAdicPoly(p, poly, root)