Skip to content

Instantly share code, notes, and snippets.

View palaniraja's full-sized avatar

palaniraja palaniraja

View GitHub Profile
@palaniraja
palaniraja / ios-build-icon.sh
Created July 25, 2020 17:29
update app icon with country code and git revcount
imgBuild="DE" && imgBuildNumer=`git rev-list --count HEAD` &&
imgPath="SRCDIR/Assets/Images.xcassets/AppIcon.appiconset" &&
convert "$imgPath/Icon-60@2x(120x120).png" -fill black -pointsize 22 -gravity North -annotate 0 "$imgBuild $imgBuildNumer" "$imgPath/Icon-60@2x(120x120).png" &&
convert "$imgPath/Icon-60@3x(180x180).png" -fill black -pointsize 26 -gravity North -annotate 0 "$imgBuild $imgBuildNumer" "$imgPath/Icon-60@3x(180x180).png" &&
convert "$imgPath/Icon-Small@3x(87x87).png" -fill black -pointsize 22 -gravity North -annotate 0 "$imgBuild" "$imgPath/Icon-Small@3x(87x87).png" &&
convert "$imgPath/Icon-Small@2x(58x58).png" -fill black -pointsize 22 -gravity North -annotate 0 "$imgBuild" "$imgPath/Icon-Small@2x(58x58).png"
@palaniraja
palaniraja / .zshrc
Last active July 23, 2020 05:54
fzf - to search history
fh() {
print -z $( ([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s --tac --height "40%" | sed -E 's/ *[0-9]*\*? *//' | sed -E 's/\\/\\\\/g')
}
# and try fh to filter the history with fzf
# source: https://armno.in.th/2020/01/16/fzf-history/
@palaniraja
palaniraja / jira.js
Created July 17, 2020 16:07
JIRA - linked lists as text
document.querySelectorAll('.links-list .link-content').forEach(el => {
console.log(el.querySelector('span').innerText)
})
@palaniraja
palaniraja / sync.swift
Created June 13, 2020 15:41
Synchronous urlrequests with delays in between, and skip/break if found
import UIKit
struct Todo: Codable {
let userId: Int
let id: Int
let title: String
var completed: Bool
}
var todos = [Todo]()
@palaniraja
palaniraja / Log.swift
Created May 23, 2020 14:46
Conditional logging to strip logs in release builds
#if DEBUG
class Log {
static func d(_ str: String){
print("Log.d: \(str)")
}
}
#else
class Log {
static func d(_ str: String) { }
}
@palaniraja
palaniraja / NSLocale+Util.swift
Created May 23, 2020 14:32
Overriding NSLocalizedString function to print the keys used for debugging purpse
/**
* prints the localization key and string requested in log for debugging purpose
*/
#if DEBUG
public func NSLocalizedString(_ key: String, tableName: String? = nil, bundle: Bundle = Bundle.main, value: String = "", comment: String) -> String
{
let str = bundle.localizedString(forKey: key, value: value, table: tableName)
debugPrint("DEBUG: \(key) -> \(str)")
return str
@palaniraja
palaniraja / string-queue.swift
Created May 16, 2020 16:01
circular queue of reserved capacity
class StrQueue: NSObject {
static let shared = StrQueue()
let kQueueLength = 3
var strings = [String]()
private override init() { }
func add(_ str: String?){
@palaniraja
palaniraja / realm-to-csv.swift
Last active April 20, 2020 13:06
Realm entity to csv export
let obj = YourRealmEntity.sharedSchema()
let props = obj?.properties
print(props)
var csvHeader = [String]()
for pid in props as! [RLMProperty]{
// print("type:\(pid.type) name: \(pid.name)")
csvHeader.append("\(pid.name)")
}
@palaniraja
palaniraja / dispatchgroup.swift
Created February 1, 2020 06:19
dispatchgroup swift playground
import UIKit
print("one")
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
print("two")
}
print("three")
func testactivation(){
@palaniraja
palaniraja / .jazzy.yaml
Created July 3, 2019 15:58
output of "jazzy --help config" from jazzy version: 0.9.6
By default, jazzy looks for a file named ".jazzy.yaml" in the source
directory and its ancestors. You can override the config file location
with --config.
(The source directory is the current working directory by default.
You can override that with --source-directory.)
The config file can be in YAML or JSON format. Available options are: