Skip to content

Instantly share code, notes, and snippets.

@wmaikon
wmaikon / Data+PrettyPrint.swift
Created May 23, 2020 03:15 — forked from cprovatas/Data+PrettyPrint.swift
Pretty print JSON string from Data in Swift 4.1 (especially useful printing to Xcode console)
import Foundation
extension Data {
var prettyPrintedJSONString: NSString? { /// NSString gives us a nice sanitized debugDescription
guard let object = try? JSONSerialization.jsonObject(with: self, options: []),
let data = try? JSONSerialization.data(withJSONObject: object, options: [.prettyPrinted]),
let prettyPrintedString = NSString(data: data, encoding: String.Encoding.utf8.rawValue) else { return nil }
return prettyPrintedString
}
@wmaikon
wmaikon / export_import_plsql.sh
Created February 12, 2020 13:06
Export postgres database from docker container
# source machine
docker exec -t containername bash -c 'pg_dump -U postgres -O dbname' > dbname.sql
# target machine
psql -U postgres -d dbname -f dbname.sql
# if you need use password make this transient change
# open file to edit:
sudo vim /etc/postgresql/POSTGRES_VERSION/main/pg_hba.conf
@wmaikon
wmaikon / uninstall-razer-synapse.sh
Created December 4, 2019 12:59 — forked from timotgl/uninstall-razer-synapse.sh
How to fully uninstall Razer Synapse 2 on OS X (10.11-10.13) (El Capitan, Sierra, High Sierra) without using Razer's official uninstall tool
# How to uninstall Razer Synapse 2 ( https://www.razerzone.com/synapse-2 )
# on OS X (10.11-10.13) (El Capitan, Sierra, High Sierra)
# without using Razer's official uninstall tool.
# Tested on OS X 10.11.5 in July 2016.
# Edited with additional steps for later OS X versions,
# contributed by commenters on this gist.
# Step 1: In your terminal: stop and remove launch agents
launchctl remove com.razer.rzupdater
@wmaikon
wmaikon / uninstall_vmware.sh
Created February 16, 2019 02:44
Completely uninstall VMWare on macOS
#!/usr/bin/env bash
# Usage: bash uninstall_vmware.bash
remove() {
entry="$1"
echo -ne "Removing $entry ["
sudo rm -rf "$entry"
if [[ ! -e "$entry" ]]; then
echo -ne "OK"
@wmaikon
wmaikon / remove_tuxera.sh
Last active August 5, 2019 01:49 — forked from miguelmota/remove_tuxera.sh
Completely uninstall and remove Tuxera NTFS on MacOs (resets trial version)
rm -rf /Applications/Tuxera\ Disk\ Manager.app
rm -rf /Library/Application\ Support/Tuxera\ NTFS
rm -rf /Library/Filesystems/fusefs_txantfs.fs
rm -rf /Library/Filesystems/tuxera_ntfs.fs
@wmaikon
wmaikon / select-all.ts
Created August 6, 2018 18:26 — forked from tperrelli/select-all.ts
Select All Directive
import { Directive, ElementRef, HostListener } from '@angular/core';
@Directive({
selector: 'ion-searchbar[select-all],ion-input[select-all]'
})
export class SelectAll {
constructor(private el: ElementRef) {
}
@wmaikon
wmaikon / sdkmanager_xmlschema_noclassdeffounderror.txt
Created July 18, 2018 13:45
sdkmanager - java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
I found two answers that worked for me, without having to uninstall JDK 10 (or 9).
Both JDK 9 and 10 are incompatible with android-sdk!
DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME"'
with:
DEFAULT_JVM_OPTS='"-Dcom.android.sdklib.toolsdir=$APP_HOME" -XX:+IgnoreUnrecognizedVMOptions --add-modules java.se.ee'
Source:
https://stackoverflow.com/questions/46402772/failed-to-install-android-sdk-java-lang-noclassdeffounderror-javax-xml-bind-a
@wmaikon
wmaikon / index.js
Created June 29, 2018 18:05 — forked from MichalZalecki/index.js
How to import RxJS 5
// Import all
import Rx from "rxjs/Rx";
Rx.Observable
.interval(200)
.take(9)
.map(x => x + "!!!")
.bufferCount(2)
.subscribe(::console.log);
@wmaikon
wmaikon / fixup.txt
Created May 10, 2018 16:35 — forked from lucasdavila/fixup.txt
Fixing mac os yosemite issue "bash: fork: Resource temporarily unavailable"
# see the current limits
$ sysctl -a | grep maxproc
# increase it
$ sudo sysctl -w kern.maxproc=xxxx
$ sudo sysctl -w kern.maxprocperuid=xxx
# run at startup
$ sudo vim /etc/sysctl.conf
@wmaikon
wmaikon / mysql-docker.sh
Created October 22, 2017 09:58 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE