Skip to content

Instantly share code, notes, and snippets.

View dimitardanailov's full-sized avatar

Dimitar Danailov (a.k.a Mitco) dimitardanailov

View GitHub Profile
@dimitardanailov
dimitardanailov / .zshrc
Last active February 23, 2024 01:34
My personal zsh and tmux configurations
# Path to your oh-my-zsh installation.
export ZSH=/Users/dimitar.danailov/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
# ZSH_THEME="robbyrussell"
ZSH_THEME="agnoster"
@dimitardanailov
dimitardanailov / create_user.sh
Last active August 9, 2023 06:16
Creating a Mac OS X user via shell script
#!/bin/sh
# https://apple.stackexchange.com/questions/82472/what-steps-are-needed-to-create-a-new-user-from-the-command-line/84039#84039
. /etc/rc.common
dscl . create /Users/administrator
dscl . create /Users/administrator RealName "Terminal User Account"
dscl . create /Users/administrator hint "Password Hint"
dscl . create /Users/administrator picture "/Path/To/Picture.png"
dscl . passwd /Users/administrator thisistheaccountpassword
@dimitardanailov
dimitardanailov / 01: basic types.ts
Last active April 22, 2023 13:45
Typescript in action
/**
* Boolean
*
* The most basic datatype is the simple true/false value,
* which JavaScript and TypeScript (as well as other languages) call a 'boolean' value.
*/
var isDone: boolean = false;
/**
* Number
@dimitardanailov
dimitardanailov / mongo-commands.md
Last active December 8, 2022 18:38
MongoDB - Commands
# Get documents, where writters are Joel Coen and Ethan Coen.
db.movieDetails.find({ "writters" : ["Joel Coen", "Ethan Coen"] }).count()
# Get documents, where Jeff Bridges is playing leading role.
> db.movieDetails.find({ "actors.0": "Jeff Bridges" }).pretty()
@dimitardanailov
dimitardanailov / 01-controllers-to-components.md
Last active August 11, 2022 01:25
Angular 2 and Typescript. Thank you to John Papa for awesome online course: http://www.johnpapa.net/angular-2-first-look

Angular 1

<body ng-controller="StoryController as vm">
  <h3>{{ vm.story.name }}</h3>
  <h3 ng-bind="vm.story.name"></h3>
</body>
@dimitardanailov
dimitardanailov / delete-index.js
Created February 17, 2022 16:12
ElasticSearch: Delete an index
'use strict'
const {Client} = require('@elastic/elasticsearch')
const client = new Client({node: 'http://localhost:9200'})
client.indices
.delete({
index: 'audit-*',
})
.then(
@dimitardanailov
dimitardanailov / signTxn.js
Created February 12, 2022 07:16
Algorand sign transaction
signTxn(sk: Uint8Array) {
// construct signed message
const sTxn: EncodedSignedTransaction = {
sig: this.rawSignTxn(sk),
txn: this.get_obj_for_encoding(),
};
// add AuthAddr if signing with a different key than From indicates
const keypair = nacl.keyPairFromSecretKey(sk);
const pubKeyFromSk = keypair.publicKey;
if (
@dimitardanailov
dimitardanailov / algorand-transaction.js
Created February 11, 2022 19:39
Algorand transaction
/**
* @resource
* https://github.com/PureStake/api-examples/blob/master/javascript-examples/algod_submit_tx.js
* https://developer.algorand.org/docs/sdks/javascript/#build-first-transaction
*/
export async function pureTransaction() {
const regExp = new RegExp(/\,/, 'g')
const mnemonic = 'final, equal, social, attack, chimney, spend, swear, civil, sad, jungle, dumb, assault, metal, feature, monitor, marriage, fly, depart, ill, shed, burger, census, swift, absent, garlic'.replace(
regExp,
'',
@dimitardanailov
dimitardanailov / algorand-wallet.js
Created January 29, 2022 07:24
Create an Account on Algorand + re-generate the address from public key
import algosdk from 'algosdk'
const createAddress = () => {
const account = algosdk.generateAccount()
const mn = algosdk.secretKeyToMnemonic(account.sk)
console.log('Account Mnemonic:', mn)
console.log('account', account)
const {publicKey, checksum} = algosdk.decodeAddress(account.addr)