Skip to content

Instantly share code, notes, and snippets.

@1905
1905 / gist:7153b0f50d6d86ae2cf2
Created November 12, 2014 18:30
Arduino ADC increase to 10-16 bit
#define potPin 0
#define ledPin 9
int potVal;
void setup()
{
/**********************************************************************************/
@1905
1905 / dateCheck.m
Created November 28, 2011 14:35
NSDate for today and last year
//date set
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *componentsToday = [calendar components:NSMinuteCalendarUnit | NSHourCalendarUnit | NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:[NSDate date]];
NSDateComponents *componentsNews = [calendar components:NSMinuteCalendarUnit | NSHourCalendarUnit | NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:comment.commentDate];
NSString *stringFromDate;
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
if([componentsToday year] == [componentsNews year]) {
if ([componentsToday day] == [componentsNews day] && [componentsToday month] == [componentsNews month]) {
[formatter setDateFormat:@"HH:mm, , Сегодня"];
stringFromDate = [formatter stringFromDate:[calendar dateFromComponents:componentsNews]];
@1905
1905 / jsonToReadable.php
Created September 25, 2011 10:31
human readable json_encode output
function jsonToReadable( $jsonString)
{
$tabcount = 0;
$result = '';
$inquote = false;
$tab = " ";
$newline = "\n";
for($i = 0; $i < strlen( $jsonString); $i++)
@1905
1905 / getUserPicture.m
Created September 18, 2011 00:51
get actual user photo (profile picture) by user id from Vkontakte, Twitter, Facebook
// get actual user picture from VKONTAKTE by UID
- (void)getUserPictureVK:(NSString*)uid
{
NSString *requestURLstring = [NSString stringWithFormat:@"https://api.vkontakte.ru/method/getProfiles?uid=%@&fields=photo", uid];
NSURL *requestURL = [NSURL URLWithString:requestURLstring];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:requestURL];
[request setTimeoutInterval:10];
AFJSONRequestOperation *operation = [AFJSONRequestOperation operationWithRequest:request
success:^(id JSON) {