Skip to content

Instantly share code, notes, and snippets.

View devraj's full-sized avatar
🚀
Building

Dev Mukherjee devraj

🚀
Building
View GitHub Profile
@andrewh
andrewh / anyconnect.scpt
Last active April 12, 2024 08:48
Applescript to automate the Cisco AnyConnect SSL VPN client on OS X Mavericks
-- 1. Place in ~/Library/Scripts and enable the Applescript menu via the Applescript Editor
-- 2. Substitute "vpn.example.com" and "redacted" for your VPN server and password
-- 3. Open Security & Privacy System Preferences, go to Privacy, Accessibility
-- 4. Enable Applescript Editor and System UI Server
-- 5. Trigger script from the menu
-- 6. Enjoy being connected
tell application "Cisco AnyConnect Secure Mobility Client"
activate
end tell
@nathansmith
nathansmith / scroll-offset.js
Last active November 27, 2023 04:51
Check if the user is scrolled to the bottom of the page.
window.onscroll = function() {
var d = document.documentElement;
var offset = d.scrollTop + window.innerHeight;
var height = d.offsetHeight;
console.log('offset = ' + offset);
console.log('height = ' + height);
if (offset >= height) {
console.log('At the bottom');
@erichiggins
erichiggins / bootstrap.py
Last active January 2, 2017 00:36
Adding Google App Engine SDK to Python virtualenv
#!/usr/bin/env python
"""
Setup a virtualenv with the Google App Engine SDK.
References:
http://virtualenv.readthedocs.org/en/latest/virtualenv.html#creating-your-own-bootstrap-scripts
http://mindtrove.info/virtualenv-bootstrapping/
"""
import hashlib
import os
@pronebird
pronebird / CoreDataDuplicateRecordsPlayground.swift
Created July 11, 2016 18:26
Fetch duplicate records with CoreData
// Playground is where kids play
import CoreData
@objc(City)
class City: NSManagedObject {
@NSManaged var name: String
}
var cityEntity = NSEntityDescription()
@db42
db42 / swift4-plist-extract.swift
Last active February 2, 2019 14:20
Swift 4 recipes: Extract data from a property list
//Property List file name = regions.plist
let pListFileURL = Bundle.main.url(forResource: "regions", withExtension: "plist", subdirectory: "")
if let pListPath = pListFileURL?.path,
let pListData = FileManager.default.contents(atPath: pListPath) {
do {
let pListObject = try PropertyListSerialization.propertyList(from: pListData, options:PropertyListSerialization.ReadOptions(), format:nil)
//Cast pListObject - If expected data type is Dictionary
guard let pListDict = pListObject as? Dictionary<String, AnyObject> else {
return
}
@jonblatho
jonblatho / PointInPolygon.swift
Last active November 13, 2023 06:31
Some Swift code to determine whether a point is inside a polygon.
/// Contains the coordinates of a point in a 2D Cartesian coordinate system.
public struct Point: Hashable {
/// The x-coordinate of the point.
public var x: Double
/// The y-coordinate of the point.
public var y: Double
}
extension Array where Element == Point {
/// Returns only the unique points in the array.
@mitchellporter
mitchellporter / README.md
Created May 30, 2019 16:44 — forked from acrookston/README.md
Xcode pre-action to build custom Info.plist

Automatic build versions from git in Xcode (and other goodies)

Installation procedure for pre-build actions to automatically populate Xcode Info.plist with dynamic data.

1. Xcode Scheme pre-action

Edit Xcode Scheme and add a pre-action script. Copy the contents of preaction.sh into the pre-action script box.

@marcojahn
marcojahn / conventional-commit-regex.md
Last active July 19, 2024 21:25
Conventional Commit Regex

the following regex will validate all examples provided here: https://www.conventionalcommits.org/en/v1.0.0/

  ^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([\w\-\.]+\))?(!)?: ([\w ])+([\s\S]*)

a grep/posix compatible variant

  ^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test){1}(\([[:alnum:]._-]+\))?(!)?: ([[:alnum:]])+([[:space:][:print:]]*)
@ts95
ts95 / Dial.swift
Last active June 13, 2024 22:21
Dial component in SwiftUI
import SwiftUI
struct Dial: View {
@Binding public var value: Double
public var minValue: Double = 0
public var maxValue: Double = .greatestFiniteMagnitude
public var divisor: Double = 1
public var stepping: Double = 1
@State private var dialAngle: Angle = .zero
@State private var dialShadowAngle: Angle = .zero
@amirdew
amirdew / View+MinimumPadding.swift
Created December 22, 2022 13:20
Minimum paddings for SwiftUI views
extension View {
func minimumPadding(edges: Edge.Set = .all, _ length: CGFloat = 8) -> some View {
GeometryReader { geo in
padding(.bottom, edges.contains(.bottom) ? max(length, geo.safeAreaInsets.bottom) : 0)
.padding(.top, edges.contains(.top) ? max(length, geo.safeAreaInsets.top) : 0)
.padding(.leading, edges.contains(.leading) ? max(length, geo.safeAreaInsets.leading) : 0)
.padding(.trailing, edges.contains(.trailing) ? max(length, geo.safeAreaInsets.trailing) : 0)
.ignoresSafeArea(edges: edges)
}
}