Skip to content

Instantly share code, notes, and snippets.

@nurse
nurse / pid2line.rb
Last active December 27, 2018 08:51
Show source files and line numers of given process's threads
#!/usr/bin/env ruby
#
# pid2line.rb
#
# Show source files and line numers of given process's threads
#
# This script works only on Linux.
# https://gist.github.com/nurse/0619b6af90df140508c2
#
@shexbeer
shexbeer / gist:cb069d36ca8ec5edb515
Last active August 31, 2018 17:00
Crops a Picture from AVCaptureSession to the bounds of the AVCaptureVideoPreviewLayer (so Preview = CameraImage)
-(UIImage*) cropCameraImage:(UIImage*) original toPreviewLayerBounds:(AVCaptureVideoPreviewLayer*) previewLayer {
UIImage *ret = nil;
CGRect previewImageLayerBounds = previewLayer.bounds;
// This calculates the crop area.
// keeping in mind that this works with on an unrotated image (so a portrait image is actually rotated counterclockwise)
// thats why we use originalHeight to calculate the width
float originalWidth = original.size.width;
float originalHeight = original.size.height;
@kishikawakatsumi
kishikawakatsumi / gist:6072953
Created July 24, 2013 18:03
Set Max Character Length UITextField (works with Japanese input method)
...
[textField addTarget:self action:@selector(editingChanged:) forControlEvents:UIControlEventEditingChanged];
...
#define MAXLENGTH 3
- (IBAction)editingChanged:(id)sender
{
UITextField *textField = sender;
@shanselman
shanselman / gist:5422230
Last active March 28, 2024 10:33
Evil Blog Comment Spammer just exposed his template through some error and the whole thing showed up in my comments.
{
{I have|I've} been {surfing|browsing} online more than {three|3|2|4} hours today, yet I never found any interesting article like yours. {It's|It
is} pretty worth enough for me. {In my opinion|Personally|In my view}, if all {webmasters|site owners|website owners|web owners} and bloggers made good content as
you did, the {internet|net|web} will be {much more|a lot more}
useful than ever before.|
I {couldn't|could not} {resist|refrain from} commenting. {Very well|Perfectly|Well|Exceptionally well} written!|
{I will|I'll} {right away|immediately} {take hold of|grab|clutch|grasp|seize|snatch}
your {rss|rss feed} as I {can not|can't} {in finding|find|to find} your {email|e-mail} subscription {link|hyperlink} or {newsletter|e-newsletter} service. Do {you have|you've} any?
{Please|Kindly} {allow|permit|let} me {realize|recognize|understand|recognise|know} {so that|in order that} I {may just|may|could} subscribe.
Thanks.|
@satococoa
satococoa / migrate_one_to_two.rb
Created November 21, 2012 01:45
RubyMotion でシンプルな CoreData のマイグレーションを行うコード
module MigrateOneToTwo
module_function
def store_path
File.join(App.documents_path, 'store.sqlite')
end
def tmp_store_path
File.join(App.documents_path, 'store_tmp.sqlite')
end
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@kozy4324
kozy4324 / index.md
Created January 23, 2012 03:44
Review_Test-Driven_JavaScript_Development