Skip to content

Instantly share code, notes, and snippets.

View mortymacs's full-sized avatar

Morteza NourelahiAlamdari mortymacs

View GitHub Profile
@michaljemala
michaljemala / tls-client.go
Last active May 23, 2025 01:11
SSL Client Authentication Golang sample
package main
import (
"crypto/tls"
"crypto/x509"
"flag"
"io/ioutil"
"log"
"net/http"
)
@betrcode
betrcode / README.md
Created June 24, 2014 06:36
Using Python to check if remote port is open and accessible.
@ctokheim
ctokheim / cython_tricks.md
Last active March 4, 2024 23:27
cython tricks

Cython

Cython has two major benefits:

  1. Making python code faster, particularly things that can't be done in scipy/numpy
  2. Wrapping/interfacing with C/C++ code

Cython gains most of it's benefit from statically typing arguments. However, statically typing is not required, in fact, regular python code is valid cython (but don't expect much of a speed up). By incrementally adding more type information, the code can speed up by several factors. This gist just provides a very basic usage of cython.

@etozzato
etozzato / acl.coffee
Last active May 31, 2016 15:20
ACL in EmberJS
FakeApp.Admin.ACL = Ember.Mixin.create
# How to USE ACL
# pass the mixin as first parameter of the route extend method and
# define the roles that are allowed
#
# ApplicationRoute = Ember.Route.extend FakeApp.Admin.ACL,
# roles: ['superuser', 'recruiter']
beforeModel: (transition) ->
return if 'unauthorized' == transition.targetName
@_super()
@basilfx
basilfx / tmux-notify.pl
Last active November 29, 2021 11:01
Irssi and tmux-notify
use strict;
use warnings;
use vars qw($VERSION %IRSSI);
use Irssi;
# Script info
$VERSION = '0.1';
%IRSSI = (
authors => 'Bas Stottelaar',
@mattes
mattes / check.go
Last active July 13, 2025 08:27
Check if file or directory exists in Golang
if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) {
// path/to/whatever does not exist
}
if _, err := os.Stat("/path/to/whatever"); !os.IsNotExist(err) {
// path/to/whatever exists
}
@michitux
michitux / anotherTest.pyx
Last active October 22, 2019 15:32
Simple example that shows a compilation problem with Cython (see error.log for the error message), fixedTest.pyx shows a workaround. anotherTest.pyx is another failing example.
# This file also fails to compile with error error: redefinition of ‘std::vector<int, std::allocator<int> > __pyx_convert_vector_from_py_int(PyObject*)’. Note that it only fails when I have another definition without the fused type.
from libcpp.vector cimport vector
cdef extern from "test.h":
cdef cppclass _TestClassInt "TestClass<int>":
vector[double] toDouble(const vector[int] &items) except +
cdef cppclass _TestClassChar "TestClass<char>":
vector[double] toDouble(const vector[char] &items) except +
@synther
synther / gist:d376100a8bae896d0caf
Last active June 16, 2025 15:51
linux signals cheat sheet
Signal Value Action Comment
SIGHUP 1 Term Hangup detected on controlling terminal or death of controlling process
SIGINT 2 Term Interrupt from keyboard
SIGQUIT 3 Core Quit from keyboard
SIGILL 4 Core Illegal Instruction
SIGABRT 6 Core Abort signal from abort(3)
SIGFPE 8 Core Floating point exception
SIGKILL 9 Term Kill signal
SIGSEGV 11 Core Invalid memory reference
SIGPIPE 13 Term Broken pipe: write to pipe with no readers
@harish-r
harish-r / AVL Tree.cpp
Created October 18, 2014 11:11
AVL Tree Implementation in C++. Self Balancing Tree
/* AVL Tree Implementation in C++ */
/* Harish R */
#include<iostream>
using namespace std;
class BST
{
@pmav99
pmav99 / config2.json
Last active June 15, 2022 14:56
Python logging configuration using JSON. If you want an updated example also covering YAML files, check here: https://github.com/pmav99/python-logging-example
{
"logging": {
"version": 1,
"disable_existing_loggers": true,
"formatters": {
"brief": {
"class": "logging.Formatter",
"datefmt": "%I:%M:%S",
"format": "%(levelname)-8s; %(name)-15s; %(message)s"
},