Skip to content

Instantly share code, notes, and snippets.

View idevsoftware's full-sized avatar

iDev Software idevsoftware

View GitHub Profile
@stevestreza
stevestreza / foo.m
Created March 23, 2012 01:37
How to add a Twitter username to an ABRecordRef
-(void)addContact{
ABRecordRef person;
ABMultiValueRef social = ABMultiValueCreateMutable(kABMultiDictionaryPropertyType);
ABMultiValueAddValueAndLabel(social, [NSDictionary dictionaryWithObjectsAndKeys:
(NSString *)kABPersonSocialProfileServiceTwitter, kABPersonSocialProfileServiceKey,
@"justinbieber", kABPersonSocialProfileUsernameKey,
nil], kABPersonSocialProfileServiceTwitter, NULL);
ABRecordSetValue(person, kABPersonSocialProfileProperty, social, NULL);
CFRelease(social);
@alloy
alloy / gist:5460654
Last active July 18, 2020 22:02
UICollectionViewFlowLayout subclass to vertically align cells at the bottom edge.
@interface MTLibraryCollectionViewFlowLayout : UICollectionViewFlowLayout
@end
@Lejdborg
Lejdborg / uitextview-margin.m
Created September 14, 2013 19:27
How to add left and right margins to a UITextView...
float padding = 10.0;
NSMutableParagraphStyle *editorParagraphStyle = [NSMutableParagraphStyle new];
[editorParagraphStyle setHeadIndent:padding];
[editorParagraphStyle setFirstLineHeadIndent:padding];
[editorParagraphStyle setTailIndent:-padding];
NSDictionary *textAttributes = @{
NSFontAttributeName: [UIFont fontWithName:@"Helvetica" size:14],
NSParagraphStyleAttributeName: editorParagraphStyle
@amatellanes
amatellanes / celery.sh
Last active July 18, 2024 07:23
Celery handy commands
/* Useful celery config.
app = Celery('tasks',
broker='redis://localhost:6379',
backend='redis://localhost:6379')
app.conf.update(
CELERY_TASK_RESULT_EXPIRES=3600,
CELERY_QUEUES=(
Queue('default', routing_key='tasks.#'),
@farirat
farirat / deliver_sm_thrower.py
Created April 27, 2015 14:09
This will publish a DeliverSM directly to the smpps thrower
from twisted.internet import defer, reactor
from jasmin.vendor.smpp.pdu.operations import DeliverSM
from jasmin.queues.configs import AmqpConfig
from jasmin.queues.factory import AmqpFactory
from jasmin.routing.jasminApi import SmppServerSystemIdConnector
from jasmin.routing.content import RoutedDeliverSmContent
from jasmin.queues.test.test_amqp import waitFor
@defer.inlineCallbacks
def connect_and_publish(pdu, dc):
@n00neimp0rtant
n00neimp0rtant / gist:27829d87118d984232a4
Last active May 24, 2019 15:10
UIVisualEffectView blur radius manipulation (new for iOS 9)
// iOS 9 allows you to animate between visual effects, which gives you the
// ability to manipulate the blur radius. this can be useful for animating
// a backdrop for a custom modal, and with a few tricks, can even be set
// indirectly, allowing you to "scrub" between them back and forth with
// a gesture, just like when you pull down Spotlight.
// these are the two effects you want to transition between
UIVisualEffect *startEffect = nil; // "nil" means no blur/tint/vibrancy (plain, fully-transparent view)
UIVisualEffect *endEffect = [UIBlurEffect effectWithStyle:UIBlurEffectStyleLight];
@NickAger
NickAger / sub.swift
Last active November 8, 2017 15:54
Understanding Swifts substringToIndex & substringFromIndex
"hello".substringToIndex(1) // "h"
// s.substringToIndex(1) // String may not be indexed with 'Int', it has variable size elements
s.substringToIndex(s.startIndex.advancedBy(1)) // "h"
s.substringFromIndex(s.startIndex.advancedBy(1)) // "ello"
s.substringFromIndex(s.endIndex.advancedBy(-1)) // "o"
s.substringToIndex(s.endIndex.advancedBy(-1)) // "hell"
@hollance
hollance / neural.c
Last active April 21, 2023 17:13
Playing with BNNS on macOS 10.12. The "hello world" of neural networks.
/*
The "hello world" of neural networks: a simple 3-layer feed-forward
network that implements an XOR logic gate.
The first layer is the input layer. It has two neurons a and b, which
are the two inputs to the XOR gate.
The middle layer is the hidden layer. This has two neurons h1, h2 that
will learn what it means to be an XOR gate.
@juanbrujo
juanbrujo / PlayStationBIOSFilesNAEUJP.md
Last active July 19, 2024 06:23
Files for PlayStation BIOS Files NA-EU-JP