Skip to content

Instantly share code, notes, and snippets.

View 9bany's full-sized avatar
🏠
Working from home

Bany 9bany

🏠
Working from home
View GitHub Profile
@9bany
9bany / LLDB.md
Last active June 24, 2021 03:07
LLDB

Explore variables value and state

expression, e, print, p, po

(lldb) print ... = (lldb) p ... = (lldb) expression -- ... = (lldb) e -- ...

Evaluate an expression on the current thread. Display any returned value with LLDB defalt formating.

  1. Usage
  • (lldb) e
  • (lldb) expression
@9bany
9bany / run.swift
Created November 9, 2021 03:42
Overlay image on the another image
extension UIImage{
func merge(mergewith: UIImage) -> UIImage {
UIGraphicsBeginImageContextWithOptions(size, false, 0.0)
let actualArea = CGRect(x: 0, y: 0, width: size.width, height: size.height)
let ratioMerge: Double = Double(mergewith.size.height / mergewith.size.width)
let widthMerge = size.height / ratioMerge
let mergeX = (size.width / 2) - (widthMerge / 2)
@9bany
9bany / run.js
Created November 12, 2021 07:03
Binary Search - Javascript
function banarySearch(key, arr, min, max, callBack) {
if (min >= max) {
return undefined;
}
const midIndex = parseInt(min + (max - min) / 2, 0.0);
const result = callBack(arr[midIndex]);
if (result > key) {
return banarySearch(key, arr, min, midIndex, callBack);
} else if (result < key) {
@9bany
9bany / binary_search.swift
Created November 12, 2021 14:57
Binary search object - Swift
// recursive
func binarySearch<T>(key: Int, arr: [T], range: Range<Int>? = nil, _ callBack: (T) -> Int) -> Int? {
var rangeDefault: Range<Int>
if let r = range {
rangeDefault = r
} else {
rangeDefault = 0..<arr.count
}
if rangeDefault.lowerBound >= rangeDefault.upperBound {
return nil
(from : https://simplifiedthinking.co.uk/2015/10/03/install-mqtt-server/ )
Installing Brew
The Mosquitto MQTT Server can be easily installed using Homebrew. If it’s not installed on your system already, then a quick visit to the homepage will give you all you need to get going. Homebrew is an OS X Package Manager for installing and updating non-Mac OS X utilities that are more commonly found in other variants of Linux. To install the basic package manager run the following command.
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Installing Mosquitto MQTT
@9bany
9bany / JSON.go
Created March 14, 2022 06:53 — forked from AlexMocioi/JSON.go
Map json to struct in GO, for direct marshal, unmarshal
package main
import "encoding/json"
import "fmt"
type Person struct {
Name string `json:"name"`
@9bany
9bany / unmaskdocker.sh
Created June 16, 2022 07:46 — forked from jthmiranda/unmaskdocker.sh
to enable again when docker daemon is masked... yet don't know why happen
# when you try to start docker
# sudo systemctl start docker
# and the output is: Failed to start docker.service: Unit docker.service is masked.
#
#
# ls -la /etc/systemd/system | grep docker
# see for /dev/null if there is
systemctl unmask docker.service
systemctl unmask docker.socket
systemctl start docker.service
@9bany
9bany / unmaskdocker.sh
Created June 16, 2022 07:46 — forked from jthmiranda/unmaskdocker.sh
to enable again when docker daemon is masked... yet don't know why happen
# when you try to start docker
# sudo systemctl start docker
# and the output is: Failed to start docker.service: Unit docker.service is masked.
#
#
# ls -la /etc/systemd/system | grep docker
# see for /dev/null if there is
systemctl unmask docker.service
systemctl unmask docker.socket
systemctl start docker.service
@9bany
9bany / merge_sort_linked_list.go
Created June 23, 2022 09:25
merge_sort_linked_list
/**
* Definition for singly-linked list.
* type ListNode struct {
* Val int
* Next *ListNode
* }
*/
func mergeTwoLists(list1 *ListNode, list2 *ListNode) *ListNode {
var dummy = new(ListNode)
var p = dummy
@9bany
9bany / run.sh
Created July 6, 2022 03:07
Docker logs container with time
docker logs --since=2022-07-05T17:30:00Z help-check-bot-cn