Skip to content

Instantly share code, notes, and snippets.

View nst's full-sized avatar

Nicolas Seriot nst

View GitHub Profile
@nst
nst / NSManagedObject+NST.h
Created April 24, 2010 20:40
Objective-C category to ease NSManagedObject usage with a single context (.h)
#import <CoreData/CoreData.h>
@interface NSManagedObject (NST)
+ (NSManagedObjectContext *)moc;
+ (NSManagedObjectModel *)mom;
+ (NSEntityDescription *)entity;
+ (NSFetchRequest *)allFetchRequest;
+ (NSArray *)allObjects;
+ (NSUInteger)allObjectsCount;
@nst
nst / NSManagedObject+NST.m
Created April 24, 2010 20:41
Objective-C category to ease NSManagedObject usage with a single context (.m)
#import "NSManagedObject+NST.h"
@implementation NSManagedObject (NST)
+ (id)create {
NSEntityDescription *entityDecription = [self entity];
NSString *name = [entityDecription name];
return [NSEntityDescription insertNewObjectForEntityForName:name inManagedObjectContext:[self moc]] ;
}
@nst
nst / orange_sms.py
Created August 8, 2012 16:38
Automates SMS sending from orange.ch
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""Automates SMS sending from orange.ch, works on 2012-08-08"""
import requests # pip install requests
import re
import sys
def get_sun_query_params():
@nst
nst / twitter.py
Created August 17, 2012 03:58
Twitter webscrapping
#!/usr/bin/env python
"""Twitter webscrapping, works on 2012-08-17
$ python twitter.py
@RonaldHayden | Firing up Uncharted 2 thanks to @chuckdude -- y'all have raised my expectations!
@CocoaSamurai | My list of Go features i'd love to see in Objective-C goo.gl/VB1Zk forgot to tweet this earlier
@slashdot | Dremel-Based Project Accepted As Apache Incubator bit.ly/N7np9P
"""
@nst
nst / mail_save_attachments.txt
Created September 21, 2012 11:53
Save attachments of selected messages in OS X Mail.app, mark the messages as read.
-- file: mail_save_attachments.txt
-- author: Nicolas Seriot
-- date: 2012-09-18
-- description: save attachments of selected messages in mail, mark the messages as read
-- usage: $ osascript mail_save_attachments.txt /some/directory
on run parameters
using terms from application "Mail"
set saveDirectory to item 1 of parameters
tell application "Mail" to set theSelectedMessages to selection

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

$ ./clitter -all YES
Clitter displays the latest favorites by your friends, using OS X settings.
By default, it remembers the latest position and will fetch only new one.
USAGE: ./clitter ([-pos POSITION] | [-all YES])
Account: nst021
Current position: 1382780540116
----------
Sat Oct 26 09:42:20 +0000 2013 @FredericJacobs favorited:
393960909083009024 [F 4] [R 4] @dlshadothman The @dailymail published an article about Aymta with a lot of wrong information.No one contacted me before publishing the article
@nst
nst / gist:8052682
Created December 20, 2013 09:55
Use STTwitter to access direct messages with web-based authentication and reverse authentication
STTwitterAPI *twitter = [STTwitterAPI twitterAPIWithOAuthConsumerName:nil
consumerKey:CONSUMER_KEY
consumerSecret:CONSUMER_SECRET];
[twitter postReverseOAuthTokenRequest:^(NSString *authenticationHeader) {
STTwitterAPI *twitterAPIOS = [STTwitterAPI twitterAPIOSWithFirstAccount];
[twitterAPIOS verifyCredentialsWithSuccessBlock:^(NSString *username) {
@nst
nst / checkurl.py
Created March 5, 2014 14:58
Test dead links from a web page list. Written to help someone on a newsgroup.
#!/usr/bin/python
__version__ = "$Revision: 0.2 $"
__author__ = "Nicolas Seriot"
__date__ = "2005-07-20"
""""
Test dead links from a web page list.
Written to help someone on a newsgroup.
@nst
nst / timer.py
Created March 5, 2014 15:00
Starts a timer. Useful for tea or cooking.
#!/usr/bin/python
# -*- coding: iso-8859-1 -*-
__version__ = "$Revision: 0.1$"
__author__ = "Nicolas Seriot"
__date__ = "2005-01-16"
""""
Her: Would you count 2 minutes and a half plase?
Me : $ timer 2 30