Skip to content

Instantly share code, notes, and snippets.

View jabedhasan21's full-sized avatar
🎯
Focusing

Jabed Bangali jabedhasan21

🎯
Focusing
View GitHub Profile
@phortuin
phortuin / postgres.md
Last active June 16, 2024 09:36
Set up postgres + database on MacOS (M1)

Based on this blogpost.

Install with Homebrew:

$ brew install postgresql@14

(The version number 14 needs to be explicitly stated. The @ mark designates a version number is specified. If you need an older version of postgres, use postgresql@13, for example.)

@radoyankov
radoyankov / Example.kt
Last active January 27, 2023 08:59
Easy Spannable on Kotlin
val spanned = spannable{ bold("some") + italic(" formatted") + color(Color.RED, " text") }
val nested = spannable{ bold(italic("nested ")) + url("www.google.com", "text") }
val noWrapping = bold("no ") + sub("wrapping ) + sup("also ") + "works"
text_view.text = spanned + nested + noWrapping
#!/bin/bash
set -e
CONTENTS=$(tesseract -c language_model_penalty_non_dict_word=0.8 --tessdata-dir /usr/local/share/tessdata/ "$1" stdout -l eng | xml esc)
hex=$((cat <<EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
@hacksalot
hacksalot / install-wkhtmltopdf-travis.md
Last active May 10, 2021 13:01
Install wkhtmltopdf on Ubuntu 16.04 LTS

Install the [latest wkhtmltopdf binary][1], extract it, and copy the wkhtmltopdf and wkhtmltoimage executables to /usr/bin/.

wget https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.4/wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
tar xf  wkhtmltox-0.12.4_linux-generic-amd64.tar.xz
cd ./wkhtmltox/bin/
sudo cp -R ./* /usr/bin/
wkhtmltopdf -V
@hasinhayder
hasinhayder / .vimrc
Created August 8, 2017 08:50
Vim Auto Indent and Syntaxt Highlighting On
syntax on
set tabstop=4
set shiftwidth=4
set expandtab
set smarttab
set autoindent
@dlimpid
dlimpid / string-md5.kt
Created July 7, 2017 09:34
Get MD5 hash of the string (of length 32, with leading zeros) in Kotlin
import java.math.BigInteger
import java.security.MessageDigest
fun String.md5(): String {
val md = MessageDigest.getInstance("MD5")
return BigInteger(1, md.digest(toByteArray())).toString(16).padStart(32, '0')
}
@sohelamin
sohelamin / socket.io-cheatsheet.md
Last active July 4, 2023 21:22
Socket.io Cheatsheet

sending to sender-client only

socket.emit('message', "this is a test");

sending to all clients, include sender

io.emit('message', "this is a test");

In JavaScript, scope is the set of variables, objects, and functions that you have access. In the other hand current context of your code.

Scope can be global, local, functional, public, private and lexical.

Lexical scope - A function within another function, the inner function has access to the scope in the outer function, this is called Lexical Scope or Closure - also referred to as Static Scope.

// Scope A
var myFunction = function () {
  // Scope B
  var name = 'Todd'; // defined in Scope B
  var myOtherFunction = function () {
 // Scope C: `name` is accessible here!

The difference between angular js service and factory.

Service and Factory both just a simple function. Service acts as a constructor function but Factory is really just a function that gets called, which is why we have to return an object explicitly. We can create & return anything that's why Factory is much more powerful and flexible.

reference: https://toddmotto.com/factory-versus-service

Here's example of Service

app.service('MyService', function () {
  this.sayHello = function () {
    console.log('hello');
  };
@milon
milon / elasticsearch_on_homestead.md
Last active November 23, 2022 15:18
Install Elasticsearch on Laravel Homestead

Install Elasticsearch on Laravel Homestead

Install Java

sudo apt-get install openjdk-7-jre-headless -y

Download & install the Public Signing Key

wget -qO - http://packages.elasticsearch.org/GPG-KEY-elasticsearch | sudo apt-key add -