Skip to content

Instantly share code, notes, and snippets.

🚀
Full reusability

Radek Pietruszewski radex

🚀
Full reusability
Block or report user

Report or block radex

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View watermelon-sync-logger.js
// @flow
import { map, is } from 'rambdax'
import type { DirtyRaw } from '@nozbe/watermelondb/RawRecord'
import type { SyncLog } from '@nozbe/watermelondb/sync'
// beginning, end, length
const censorValue = (value: string): string =>
`${value.slice(0, 2)}***${value.slice(-2)}(${value.length})`
const shouldCensorKey = (key: string): boolean =>
View prefetch-use
1. set up a Prefetcher instance, for example in your router component
2. when you want to display another part of the app, call:
```
prefetcher.prefetch(screenConcretePrefetcher, 'my-screen', () => {
// prefetch done! you can call setState() or whatever to actually start rendering a tree
})
```
@radex
radex / tadam-es.strings
Last active Jun 14, 2018
This is my best take on translating strings for Tadam http://tadamapp.com into Spanish. If you're a native Spanish speaker, please send corrections! Much appreciated 🙏
View tadam-es.strings
/* !!! As always: you don't have to translate verbatim. Feel free to change things a bit if it makes more sense in a language, as long as you keep the meaning. */
/* ## new timer view ## */
/* New timer */
"new_timer.title" = "Nuevo temporizador";
/* Go! */
"go.title" = "Iniciar";
/* ## change time view ## */
/* Change time */
"change_time.title" = "Cambiar tiempo";
View capturedGroups.swift
extension NSRegularExpression {
func capturedGroups(forString string: String) -> [String?]? {
let nsString = string as NSString
let stringRange = NSRange(location:0, length: nsString.length)
// Match
guard let result = firstMatchInString(string, options: [], range: stringRange) else {
return nil
}
View podfile-xcode8.rb
post_install do |installer|
installer.pods_project.build_configurations.each do |configuration|
configuration.build_settings['SWIFT_VERSION'] = '2.3'
configuration.build_settings['PROVISIONING_PROFILE_SPECIFIER'] = 'WT398A4BZ6/' # replace with your Team ID
end
end
@radex
radex / extract-methods.rb
Created Feb 11, 2016
Extract function declarations from your Swift project. Just open up `irb` from your project run and paste this:
View extract-methods.rb
IO.write 'funcs.txt', (Dir["**/*.swift"] - Dir["{Libraries,Pods}/**/*.swift"]).flat_map { |f| IO.read(f).lines.select { |l| l.include? 'func ' }.map { |l| l.strip } }.join("\n")
View euler15.swift
// Dumb (and really slow)
import Foundation
func combinations(height: Int, _ level: Int) -> Int {
if (level == 1) {
return height + 1
} else {
var sum = 0
for i in 0...height {
@radex
radex / hard-reproductions.md
Last active Jan 30, 2016
Trouble reproducing a bug? Run this checklist.
View hard-reproductions.md

Trouble reproducing a bug? Run this checklist to make sure you're reproducing user's environment as closely as possible:

Device

  • iOS version?
  • iPad/iPhone?
  • CPU architecture?
  • Screen size? Orientation? Slide-over/Split View?

iOS settings

View ugly.swift
// Option 1: if..elseif + optional unwrapping conditions
private func handleNotificationAction(id: String?, userInfo: [NSObject: AnyObject], responseInfo: [NSObject: AnyObject]?, completion: () -> Void) {
let taskId = userInfo["extra"]?["task_hash"] as? String
let projectId = userInfo["extra"]?["project_hash"] as? String
let comment = responseInfo?["UIUserNotificationActionResponseTypedTextKey"] as? String
if id == "comment", let task = taskId, comment = comment where !comment.isEmpty {
} else if id == "invitation_accept", let project = projectId {
@radex
radex / crash2.swift
Last active Aug 29, 2015
Swift crash: double subscript declaration
View crash2.swift
class Foo {
subscript(key: String) -> String {
get { a }
set { b }
}
subscript(key: String) -> String {
get { a }
set { b }
}
You can’t perform that action at this time.