Skip to content

Instantly share code, notes, and snippets.

View chashmeetsingh's full-sized avatar
👨‍💻
/* No Comment */

Chashmeet Singh chashmeetsingh

👨‍💻
/* No Comment */
View GitHub Profile
//
// NewModel.swift
// Susi
//
// Created by Chashmeet Singh on 2017-06-08.
// Copyright © 2017 FOSSAsia. All rights reserved.
//
import RealmSwift
import Realm
def naked_twins(values):
"""Eliminate values using the naked twins strategy.
Args:
values(dict): a dictionary of the form {'box_name': '123456789', ...}
Returns:
the values dictionary with the naked twins eliminated from peers.
"""
twins = []
@chashmeetsingh
chashmeetsingh / only_choice
Last active May 19, 2017 09:08
only_choice
from utils import *
def only_choice(values):
for unit in unitlist:
for box in unitlist:
val = ''
for item in box:
if len(values[item]) > 1:
val += values[item]
s = ''
List<NameValuePair> someVariable = new ArrayList<NameValuePair>();
nameValuePairs.add(new BasicNameValuePair("query", "{articles{id}}"));
HttpClient httpclient=new DefaultHttpClient();
HttpPost httppost = new HttpPost("http://udacity-alumni-api.herokuapp.com/graphql");
httppost.setHeader(HTTP.CONTENT_TYPE,"application/x-www-form-urlencoded;charset=UTF-8");
try {
httppost.setEntity(new UrlEncodedFormEntity(someVariable, "UTF-8"));
} catch (UnsupportedEncodingException e) {
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "jp.ogwork.freetransform"
minSdkVersion 15
targetSdkVersion 24
@chashmeetsingh
chashmeetsingh / timeago.swift
Created August 2, 2016 01:08
"Time ago" function for Swift (based on MatthewYork's DateTools for Objective-C) *Swift 3
func timeAgoSinceDate(date:NSDate, numericDates:Bool) -> String {
let calendar = Calendar.current
let now = NSDate()
let earliest = now.earlierDate(date as Date)
let latest = (earliest == now) ? date : now
let components:NSDateComponents = calendar.components([Calendar.Unit.minute , Calendar.Unit.hour , Calendar.Unit.day , Calendar.Unit.weekOfYear , Calendar.Unit.month , Calendar.Unit.year , Calendar.Unit.second], from: earliest, to: latest as Date, options: Calendar.Options())
if (components.year >= 2) {
return "\(components.year) years ago"
} else if (components.year >= 1){
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
let navigationController: AppNavigationController = AppNavigationController(rootViewController: VideoViewController())
let menuViewController: AppMenuController = AppMenuController(rootViewController: navigationController)
menuViewController.edgesForExtendedLayout = .None
let tabBarController: BottomNavigationController = BottomNavigationController()
tabBarController.viewControllers = [RecipesViewController(), menuViewController, PhotoViewController()]
tabBarController.selectedIndex = 1
tabBarController.tabBar.tintColor = MaterialColor.white
import UIKit
import SpriteKit
import ParticlesLoadingView
class ViewController: UIViewController {
lazy var loadingView: ParticlesLoadingView = {
let x = UIScreen.mainScreen().bounds.size.width / 2 - (75 / 2) - 200
let y = UIScreen.mainScreen().bounds.size.height / 2 - (75 / 2)
let view = ParticlesLoadingView(frame: CGRect(x: x, y: y, width: 75, height: 75))