Skip to content

Instantly share code, notes, and snippets.

View verebes1's full-sized avatar

David verebes1

View GitHub Profile
@gelitenight
gelitenight / Example.java
Last active November 8, 2023 08:42
A way to easily traverse any view hierarchy in Android
/* basic usage */
ViewGroup root = (ViewGroup) findViewById(android.R.id.content);
LayoutTraverser.build(new LayoutTraverser.Processor() {
@Override
public void process(View view) {
// do stuff with the view
}
}).traverse(root);
@lfender6445
lfender6445 / gist:9919357
Last active November 18, 2024 20:32
Pry Cheat Sheet

Pry Cheat Sheet

Command Line

  • pry -r ./config/app_init_file.rb - load your app into a pry session (look at the file loaded by config.ru)
  • pry -r ./config/environment.rb - load your rails into a pry session

Debugger

@coryalder
coryalder / UIImage+Invert.swift
Created March 12, 2015 05:42
Invert a UIImage at runtime using Core Image CIFilter + CIContext
extension UIImage {
func invertedImage() -> UIImage? {
let img = CoreImage.CIImage(CGImage: self.CGImage)
let filter = CIFilter(name: "CIColorInvert")
filter.setDefaults()
filter.setValue(img, forKey: "inputImage")
@squarism
squarism / iterm2.md
Last active November 19, 2024 15:14
An iTerm2 Cheatsheet

Tabs and Windows

Function Shortcut
New Tab + T
Close Tab or Window + W (same as many mac apps)
Go to Tab + Number Key (ie: ⌘2 is 2nd tab)
Go to Split Pane by Direction + Option + Arrow Key
Cycle iTerm Windows + backtick (true of all mac apps and works with desktops/mission control)
@mitulmanish
mitulmanish / TwoDimensionalArray.swift
Created July 6, 2016 07:03
Iterating over 2D array in Swift(with indices)
let twoDimArr: [[Int]] = [[0, 0, 1], [1, 0, 1]]
for (i,row) in twoDimArr.enumerate() {
for (j, cell) in row.enumerate() {
print("m[\(i),\(j)] = \(cell)")
print("**************")
}
}
@dmathewwws
dmathewwws / URLSession POST.swift
Created November 5, 2016 01:35
URLSession POST request example
private static func createUserEventData(user:SKUser, eventType:SKEventType, sticker:Sticker?) {
// server endpoint
let endpoint = "https://app.stickerkit.io/userEvent/v1/\(user.projectID)"
guard let endpointUrl = URL(string: endpoint) else {
return nil
}
//Make JSON to send to send to server
@krodak
krodak / Realm+CascadeDeleting.swift
Last active April 27, 2023 19:16
Cascade deletion for RealmSwift
import RealmSwift
import Realm
protocol CascadeDeleting: class {
func delete<Entity>(_ list: List<Entity>, cascading: Bool)
func delete<Entity>(_ results: Results<Entity>, cascading: Bool)
func delete<Entity: Object>(_ entity: Entity, cascading: Bool)
}
@TomSoderling
TomSoderling / Disable iOS Simulator Incoming Connections Popup.sh
Last active December 14, 2023 10:26
Bash script for turning off the iOS simulator pop-up message
#!/bin/bash
# Script to disable the iOS Simulator app from showing the "Do you want the application xxxx to accept incoming network connections?" pop-up every time the app is run
echo "> Enter password to temporarily shut firewall off"
sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off
echo "> Add Xcode as a firewall exception"
/usr/libexec/ApplicationFirewall/socketfilterfw --add /Applications/Xcode.app/Contents/MacOS/Xcode
@ankitthakur
ankitthakur / Network.swift
Created December 14, 2018 16:17
Swift Network Request
public class Network:NSObject, URLSessionDelegate, URLSessionTaskDelegate, URLSessionDataDelegate {
internal static let sharedInstance = Network()
fileprivate var networkParams:Array<NetworkParams> = Array()
fileprivate func networkCall(_ request:URLRequest, completionBlock:@escaping NetworkCompletionBlock)
{
let configurationId = String(format: "Network%d", arc4random())
let configuration = URLSessionConfiguration.background(withIdentifier: configurationId)
configuration.timeoutIntervalForRequest = request.timeoutInterval
@oseme-techguy
oseme-techguy / Correct_GnuPG_Permission.sh
Last active November 4, 2024 08:39
This fixes the " gpg: WARNING: unsafe permissions on homedir '/home/path/to/user/.gnupg' " error while using Gnupg .
#!/usr/bin/env bash
# To fix the " gpg: WARNING: unsafe permissions on homedir '/home/path/to/user/.gnupg' " error
# Make sure that the .gnupg directory and its contents is accessibile by your user.
chown -R $(whoami) ~/.gnupg/
# Also correct the permissions and access rights on the directory
chmod 600 ~/.gnupg/*
chmod 700 ~/.gnupg