Skip to content

Instantly share code, notes, and snippets.

View mortymacs's full-sized avatar

Morteza NourelahiAlamdari mortymacs

View GitHub Profile
@mbinna
mbinna / effective_modern_cmake.md
Last active May 15, 2025 16:53
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@fulldecent
fulldecent / travis-local.md
Created November 29, 2017 02:33
Run Travis build locally

travis-local.md

Preconditions:

  1. POSIX or Windows system
  2. Install Docker
  3. A GitHub repo that already builds on Travis

Postcondition:

@mortymacs
mortymacs / openldap-get-changed-users.md
Created November 11, 2017 12:28
How to get OpenLdap user changed attributes instead of all user attributes

To handle this issue, you need to get openldap internal fields by adding a + sign at the end of search query like so:

    $ ldapsearch -h localhost -w 'admin' -x -D "cn=admin,dc=example,dc=org" -b "DC=example,DC=org" +

And in python code it would like this:

    r = l.search_ext("dc=example,dc=org", ldap.SCOPE_SUBTREE, "objectClass=*", ["+",], 0)
@mortymacs
mortymacs / increase-emacs-startup.md
Last active February 18, 2020 19:33
Increase emacs startup speed

Add this line in /etc/profile:

if [ ! `ps -x | grep emacs | grep daemon | awk '{ print $2 }'` ]; then
  emacs --daemon 2> /dev/null
fi

Relogin again to start the daemon.

Now you can edit your files with emacsclient command like so:

@mortymacs
mortymacs / openvpn-conf.md
Last active November 21, 2017 11:47 — forked from narbehaj/create-client.sh
OpenVPN Server Configuration for GNU/Linux Servers

OpenVPN Config

apt-get install openvpn easy-rsa
mkdir /etc/openvpn/easy-rsa
cp -rf /usr/share/easy-rsa/* /etc/openvpn/easy-rsa
cp /etc/openvpn/easy-rsa/openssl-1.0.0.cnf /etc/openvpn/easy-rsa/openssl.cnf

Edit the vars file in order to create certificates information:

@narbehaj
narbehaj / create-client.sh
Last active November 21, 2017 11:37
OpenVPN Server Configuration for GNU/Linux Servers
#!/bin/bash
source /etc/openvpn/easy-rsa/vars
client=$1
/etc/openvpn/easy-rsa/build-key $client
mkdir -p /tmp/tmp-vpn-client/$client
cp /etc/openvpn/easy-rsa/keys/$client.* /tmp/tmp-vpn-client/$client/
cp /etc/openvpn/easy-rsa/keys/ca.crt /tmp/tmp-vpn-client/$client/
@mortymacs
mortymacs / Default (Linux).sublime-keymap
Last active February 8, 2018 21:21
My sublimetext 3 config
[
{"keys": ["alt+d"], "command": "sublime_jedi_goto"},
{"keys": ["alt+f"], "command": "jump_back"},
{"keys": ["alt+b"], "command": "blame"},
// {"keys": ["alt+d"], "command": "goto_definition"}
]
@mortymacs
mortymacs / proxy-jump-ssh-connection.md
Last active March 28, 2018 01:53
Proxy Jump in SSH Connections

Create config file for ssh (my.conf):

Host Server1
    User root
    HostName 192.168.100.10
Host Server2
    User root
    HostName 192.168.100.5
Host Server3
 User root
@mortymacs
mortymacs / send-read-message.md
Last active April 10, 2019 01:44
Send and Read Message in a Python Process Via stdin in GNU/Linux

To read message from stdin try this sample code:

import time
import sys

while True:
    for i in sys.stdin:
        print(i)
    time.sleep(2)
@flaviocopes
flaviocopes / check-substring-starts-with.go
Last active June 23, 2024 09:05
Go: check if a string starts with a substring #golang
package main
import (
"strings"
)
func main() {
strings.HasPrefix("foobar", "foo") // true
}