Skip to content

Instantly share code, notes, and snippets.

View nbhasin2's full-sized avatar

Nishant Bhasin nbhasin2

View GitHub Profile
@nbhasin2
nbhasin2 / Git_Tips.md
Last active August 29, 2015 14:10
Git General Tips (Rebase & Squash)

##Git Rebase and Squash - Tips

Git Rebase

Say you are on your branch.

  1. Commit your changes (git add .) and (git commit -m "your message")
  2. Checkout master (git checkout master)
  3. Update master (git pull master)
  4. Checkout your branch (git checkout "your branch name")
  5. Rebase changes from master (git rebase master)
@nbhasin2
nbhasin2 / Ubuntu_list_package_installed_per_day.md
Last active August 29, 2015 14:10
List the packages installed in ubuntu server.

##Package Installed

###Date There is a simple way to see all packages installation date. Go to:

cd /var/log Search for all dpkg.log, dpkg.log.1 by for example executing:

ls | grep 'dpkg.log'
and type:

@nbhasin2
nbhasin2 / Swift_Method_Call.swift
Last active August 29, 2015 14:10
Swift Tips and Tricks (iOS)
// Ref - http://stackoverflow.com/questions/24045890/why-does-a-function-call-require-the-parameter-name-in-swift
Functions
Suppose you define this:
func multiply1(f1: Double, f2: Double) -> Double {
return f1 * f2
}
Parameter names are here only local to the function, and cannot be used when calling the function:
@nbhasin2
nbhasin2 / Thread_management_iOS.swift
Created January 20, 2015 21:53
Multi Threading in Swift (iOS) using Dispatch Group
//Group 4 will be executed last after 1-3 are done executing
//Multi Threadin in Swift Group Dispatch Example
//Global Dispatch Queue
let dispatchGroup = dispatch_group_create()
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), {
@nbhasin2
nbhasin2 / Orientation.swift
Created January 21, 2016 18:56
Orientation.swift
override func didRotateFromInterfaceOrientation(fromInterfaceOrientation: UIInterfaceOrientation) {
var text=""
switch UIDevice.currentDevice().orientation{
case .Portrait:
self.delegate?.reloadButtons!()
case .PortraitUpsideDown:
text="PortraitUpsideDown"
case .LandscapeLeft:
text="LandscapeLeft"
case .LandscapeRight:
@nbhasin2
nbhasin2 / Ble.swift
Last active November 27, 2016 09:49
Bluetooth Discovery / Connection
More links -
http://clover-lemongrass.cloudvent.net/blog/2015/06/11/zero-to-ble-on-ios-part-one/
http://clover-lemongrass.cloudvent.net/blog/2015/10/15/developing-ios-app-using-ble-standard/
Here is the complete code to discover peripheral, connect to it and discover its services and characteristics.
1.Connect peripheral
func centralManager(central: CBCentralManager, didDiscoverPeripheral peripheral: CBPeripheral, advertisementData: [String : AnyObject], RSSI: NSNumber) {
diff --git a/Client.xcodeproj/project.pbxproj b/Client.xcodeproj/project.pbxproj
index b0a2f2129..a1345ccc4 100644
--- a/Client.xcodeproj/project.pbxproj
+++ b/Client.xcodeproj/project.pbxproj
@@ -252,6 +252,8 @@
435D7CC02461EFCB0043ACB9 /* IntroScreenWelcomeViewV2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 435D7CBF2461EFCB0043ACB9 /* IntroScreenWelcomeViewV2.swift */; };
435D7CC32461EFDD0043ACB9 /* IntroScreenSyncViewV2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 435D7CC22461EFDD0043ACB9 /* IntroScreenSyncViewV2.swift */; };
435D7CC5246209AA0043ACB9 /* IntroViewControllerV2.swift in Sources */ = {isa = PBXBuildFile; fileRef = 435D7CC4246209AA0043ACB9 /* IntroViewControllerV2.swift */; };
+ 4360D9AC24943AF10041EE16 /* ListSelectionController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4360D9AB24943AF10041EE16 /* ListSelectionController.swift */; };
+ 4360D9AF24943C220041EE16 /* LoginDataSource.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4360D9AE24943C220041EE16
@nbhasin2
nbhasin2 / LocalNotificationPermission.swift
Last active May 10, 2021 01:55
Local Notification Swift Permission
let center = UNUserNotificationCenter.current()
center.getNotificationSettings { permission in
switch permission.authorizationStatus {
case .authorized:
print("Authorized")
case .denied:
print("Denied")
case .ephemeral:
print("Temporary notification for App Clips")
@nbhasin2
nbhasin2 / sample_experiment
Created July 6, 2021 18:18
sample_experiment.json
{
"data": [
{
"slug": "android-keystore-reliability-experiment-v3",
"appId": "org.mozilla.firefox",
"appName": "fenix",
"channel": "release",
"endDate": null,
"branches": [
{

Keybase proof

I hereby claim:

  • I am nbhasin2 on github.
  • I am nbhasin (https://keybase.io/nbhasin) on keybase.
  • I have a public key ASD2iy7cgeZ217gBxezjgO0YbEz5StVZnUm6lydmHITa-go

To claim this, I am signing this object: