Skip to content

Instantly share code, notes, and snippets.

@vseow
vseow / apm-uninstall.sh
Created November 10, 2015 23:19
Uninstall multiple packages from Atom editor in the command line
apm list -b | grep [KEYWORD] | xargs apm uninstall
@vseow
vseow / wget.sh
Created November 10, 2015 23:17
Download from multiple links/URLs in a text file with wget
wget --content-disposition -i list-of-links.txt
# Make sure your URLs are in the following format: http://www.example.com
@vseow
vseow / mongorestore.sh
Created August 7, 2015 22:39
Run mongorestore on Remote Target
mongorestore --host [IP/HOSTNAME] --port [PORT] --db [DB_NAME] --username [USER] --password [PASS] --collection [COLLECTION_NAME] dump/db/col.bson
@vseow
vseow / index.php
Last active September 3, 2019 09:35
Get Country from IP with PHP
<?php
$ip = $_SERVER['REMOTE_ADDR'];
//echo $ip;
// Docs: http://ip-api.com/docs/
// Capped at 250 lookups/min - can unban yourself if you go over http://ip-api.com/docs/unban
$xml = simplexml_load_file("http://ip-api.com/xml/".$ip);
echo $xml->country;
@vseow
vseow / .gitignore
Created August 7, 2015 22:36
.gitignore for Xcode 6
# Xcode
.DS_Store
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
@vseow
vseow / update.php
Created August 7, 2015 22:35
Update Beacon Info with PHP (Kontakt)
<?php
$url = 'https://api.kontakt.io/beacon/update?uniqueId=';
$prox = 'f7826da6-4fa2-4e98-8024-bc5b71e0893e'; // Example UUID
$did = 'lsuVg'; // Example Device ID, Unique ID
$alias = 'Example';
$privKey = 'insert-your-api-key-here';
@vseow
vseow / get.php
Created August 7, 2015 22:31
Get Beacon Info with PHP (Kontakt)
<?php
$url = 'https://api.kontakt.io/beacon?proximity=';
$prox = 'f7826da6-4fa2-4e98-8024-bc5b71e0893e'; // Example UUID
$major = '37579';
$minor = '51992';
$privKey = 'insert-your-api-key-here';
@vseow
vseow / badge.m
Created August 7, 2015 20:54
Set Badge Notification Number on App Icon (iOS)
- (void)application:(UIApplication *)application didReceiveRemoteNotification: (NSDictionary *)userInfo {
NSLog(@"userInfo:%@",userInfo);
badge_value+=[[[userInfo objectForKey:@"aps"] objectForKey:@"badge"]intValue];
NSLog(@"Total badge Value:%d",badge_value);
for (id key in userInfo) {
NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
}
@vseow
vseow / s3cmd_sync.sh
Created August 7, 2015 20:50
Backing Up to Amazon S3
# Command Line to run from terminal
# Logs result to file s3_backup.log
# Command will run in the background
s3cmd sync -v /path/to/folder/ s3://s3-bucket/folder/ > s3_backup.log 2>&1 &
# Crontab command to sync folder to S3
# Command will run 1am every day and logs result to /root/s3_backup.log
0 1 * * * /usr/bin/s3cmd sync -rv /path/to/folder/ s3://s3-bucket/folder/ >> /root/s3_backup.log
@vseow
vseow / getVendorID.m
Created August 7, 2015 20:49
Get Vendor ID iOS
NSString *udid;
udid = [UIDevice currentDevice].identifierForVendor.UUIDString;