Skip to content

Instantly share code, notes, and snippets.

@knightbenax
knightbenax / authViewModel.swift
Created July 22, 2023 20:26
Example GraphQL implementation
class AuthViewModel : BaseViewModel {
func loginUser(email: String, password: String, completion: @escaping (_ success : Bool, _ error : NSError?) -> Void){
Network.shared.apollo.perform(mutation: BundulAPI.LoginUserMutation(loginInput: NameOfAPI.LoginInput(email: email, password: password))) { result in
switch result {
case .success(let graphQLResult):
print("Success! Result: \(graphQLResult)")
completion(true, nil)
case .failure(let error):
print("Failure! Error: \\(error)")
@knightbenax
knightbenax / months.swift
Created August 28, 2022 21:16
Months as array in Swift.
let month = ["January","February","March","April","May","June","July",
"August","September","October","November","December"]
let month = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul","Aug", "Sep", "Oct", "Nov", "Dec"]
@knightbenax
knightbenax / touchbar.swift
Last active August 28, 2022 21:18
Touchbar in SwiftUI for macOS
struct Home: View {
var body: some View {
VStack(){
}
.focusable()
.touchBar{
HStack(spacing: 5){
Button(action: { zoomMinus() }) {
Image("minus.magnifyingglass").font(.system(size: 18, weight: .light))
}.padding([.trailing, .leading], 5).buttonStyle(PlainButtonStyle()).tooltip("Zoom Out")
'use strict';
// server.js
// load the things we need
//This is to parse the arguments from the cmd line
const optimist = require('optimist');
//listen for our initial argument.
const abArray = optimist.argv["array"];
let insideArray = [1,2,3,[1,2,[4,5],3,4],2];
let passedInput = true;
let cardParams = PSTCKCardParams.init()
let cardNumber: String = cardNumbField.text!
let ccvFieldString: String = ccvField.text!
cardParams.number = cardNumber
cardParams.cvc = ccvFieldString
cardParams.expYear = 2020
cardParams.expMonth = 9
func getIfImageHasTransparentBackground(image: NSImage) -> Bool {
var hasTransparentBackground : Bool = false
let cgImage = image.cgImage
let context = createARGBBitmapContextFromImage(cgImage: cgImage!)
let height = cgImage!.height
let width = cgImage!.width
let rect: CGRect = CGRect(x: 0, y: 0, width: CGFloat(width), height: CGFloat(height))
context?.draw(cgImage!, in: rect)
@knightbenax
knightbenax / nigerian_banks.txt
Created September 22, 2018 16:23
List of Nigerian Banks for use in an Android Spinner
"Access Bank" , "Citibank", "Diamond Bank", "Dynamic Standard Bank", "Ecobank Nigeria", "Fidelity Bank Nigeria", "First Bank of Nigeria", "First City Monument Bank", "Guaranty Trust Bank", "Heritage Bank Plc","Jaiz Bank","Keystone Bank Limited", "Providus Bank Plc", "Skye Bank", "Stanbic IBTC Bank Nigeria Limited", "Standard Chartered Bank", "Sterling Bank", "Suntrust Bank Nigeria Limited", "Union Bank of Nigeria", "United Bank for Africa", "Unity Bank Plc", "Wema Bank", "Zenith Bank"
@knightbenax
knightbenax / quick_fix_padding_bottom_app_bar.java
Created September 10, 2018 08:22
Quick fix for padding clipping menu items in BottomAppBar
/**
* Setting the padding on the BottomAppBar instead clips out the menuview for some
* reasons. Feel it's a bug.
*
* So instead would just get the ActionMenuView which houses the menu and apply the
* padding to that instead.
*
* Reuben 1. Google 0.
* **/
for(int i = 0; i < bottomAppBar.getChildCount(); ++i) {
@knightbenax
knightbenax / CustomDarkUIView.swift
Last active May 12, 2018 22:59
GradientView in Swift/iOS
import UIKit
class CustomDarkUIView: UIView {
let gradientLayer = CAGradientLayer()
override func layoutSubviews() {
// resize your layers based on the view's new frame
@knightbenax
knightbenax / stuns
Created February 10, 2014 10:54 — forked from zziuni/stuns
# source : http://code.google.com/p/natvpn/source/browse/trunk/stun_server_list
# A list of available STUN server.
stun.l.google.com:19302
stun1.l.google.com:19302
stun2.l.google.com:19302
stun3.l.google.com:19302
stun4.l.google.com:19302
stun01.sipphone.com
stun.ekiga.net