Skip to content

Instantly share code, notes, and snippets.

View nishabe's full-sized avatar

nish abe nishabe

View GitHub Profile
@nishabe
nishabe / SWIFT: AlertViewController
Created August 12, 2018 18:29
SWIFT: AlertViewController
let alert = UIAlertController(title: "Alert Title", message: "Alert Message", preferredStyle: UIAlertControllerStyle.alert)
alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { action in
switch action.style{
case .default:
print("default")
case .cancel:
print("cancel")
case .destructive:
print("destructive")
}}))
/* Arduino IOT - Temperature (oC) and Humidity (%) on the web
*Use the DHT-22 sensor to read temperature and humidity values
*Send these values to www.thingSpeak.com with the ESP8266 serial Wifi module
Dev: Michalis Vasilakis // Date:23/2/2016 // Update: 25/2/2015 // Ver. 1.3
More info: http://www.ardumotive.com/iot-wifi-temp-and-humidity.html
Tip: open the serial monitor for debugging */
//Libraires
#include <stdlib.h>
#include <DHT.h>
\curl -sSL https://get.rvm.io | bash -s stable –ruby 
rvm install 2.4.2 
rvm use 2.4.2
gem install sinatra
@nishabe
nishabe / README.md
Last active March 13, 2018 20:35 — forked from jonathantneal/README.md
Local SSL websites on macOS High Sierra

Local SSL websites on macOS High Sierra

These instructions will guide you through the process of setting up local, trusted websites on your own computer.

These instructions are intended to be used on macOS Sierra, but they have been known to work in El Capitan, Yosemite, Mavericks, and Mountain Lion.

NOTE: You may substitute the edit command for nano, vim, or whatever the editor of your choice is. Personally, I forward the edit command to Sublime Text:

alias edit="/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"
@nishabe
nishabe / OBJC: Pulsing View Animation
Last active August 12, 2018 18:24
OBJC: Pulsing View Animation
-(void)showPulsingAnimation {
CABasicAnimation *theAnimation;
theAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];
theAnimation.duration = 2.0;
theAnimation.repeatCount = HUGE_VALF;
theAnimation.autoreverses = YES;
theAnimation.fromValue = [NSNumber numberWithFloat:1.0];
theAnimation.toValue = [NSNumber numberWithFloat:0.0];
[self.pulsingView.layer addAnimation:theAnimation forKey:@"animateOpacity"];
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.folderbackup.job</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
@nishabe
nishabe / OBJC: HMAC creation - Pass Key and Data as NSData.txt
Last active August 12, 2018 18:23
OBJC: HMAC creation - Pass Key and Data as NSData
- (NSData *)generateHMACwith:(NSData *)key key:(NSData *)data {
NSMutableData *macOut = [NSMutableData dataWithLength:CC_SHA256_DIGEST_LENGTH];
CCHmac( kCCHmacAlgSHA256,
key.bytes,
key.length,
data.bytes,
data.length,
macOut.mutableBytes);
return macOut;
}
@nishabe
nishabe / OBJC: HMAC creation - Pass Key and Data as String.txt
Last active August 12, 2018 18:23
OBJC: HMAC creation - Pass Key and Data as String
-(NSString*)generateHMACwith :(NSString* )key :(NSString*)data{
const char *cKey = [key cStringUsingEncoding:NSUTF8StringEncoding];
const char *cData = [data cStringUsingEncoding:NSUTF8StringEncoding];
unsigned char cHMAC[CC_SHA256_DIGEST_LENGTH];
CCHmac(kCCHmacAlgSHA256,
cKey,
strlen(cKey),
cData,
strlen(cData),
cHMAC);
@nishabe
nishabe / OBJC: Read text from File
Last active August 12, 2018 18:23
OBJC: Read text from File
- (NSString*)readString{
NSURL *filePath = [[NSBundle mainBundle] URLForResource:@"info" withExtension:@"txt"];
NSString *path = [filePath path];
NSString *content = @"";
if([[NSFileManager defaultManager] fileExistsAtPath:path]) {
// Do something here
content = [NSString stringWithContentsOfFile:path
encoding:NSUTF8StringEncoding
error:NULL];
}
@nishabe
nishabe / OBJC: PRETTY FUNCTION
Last active August 12, 2018 18:23
OBJC: PRETTY FUNCTION
NSLog(@"%s",__PRETTY_FUNCTION__);