Skip to content

Instantly share code, notes, and snippets.

View mjavadhpour's full-sized avatar
:octocat:

M.J. mjavadhpour

:octocat:
  • The Earth
View GitHub Profile
@thisismzm
thisismzm / exphp
Last active May 3, 2018 23:51
This is a bash script for switch between PHP versions that are enable as Apache2 webserver module.
#!/bin/bash
sudo update-alternatives --set php "/usr/bin/php$2";
sudo update-alternatives --set "php-config" "/usr/bin/php-config$2";
sudo update-alternatives --set phpize "/usr/bin/phpize$2";
sudo a2dismod "php$1"
sudo a2enmod "php$2"
sudo service apache2 restart
@xeptore
xeptore / CMakeLists.txt
Last active July 5, 2019 11:45
cpp vscode development (cmake, build, and debugging) configurations
cmake_minimum_required (VERSION 3.10)
project (main)
# book.cpp implementing book.h definitions
add_library(Book book.h book.cpp)
add_executable(main main.cpp)
# linking Book library to main
target_link_libraries (main Book)
# Set permission of all files and folders. 755 and 644.
find . -type d -exec chmod 755 {} \;
find . -type f -exec chmod 644 {} \;
find ./app/cache -type d -exec chmod 777 {} \;
find ./app/logs -type d -exec chmod 777 {} \;
find ./web/upload -type d -exec chmod 777 {} \;
#find /opt/lampp/htdocs -type d -exec chmod 755 {} \;
#find /opt/lampp/htdocs -type f -exec chmod 644 {} \;
@TalAter
TalAter / idb.js
Created September 13, 2016 10:49
IndexedDB upgrade code to add index to an existing object store
request.onupgradeneeded = function(event) {
var db = event.target.result;
var upgradeTransaction = event.target.transaction;
var objectStore;
if (!db.objectStoreNames.contains("my-store")) {
objectStore = db.createObjectStore("my-store");
} else {
objectStore = upgradeTransaction.objectStore('my-store');
}
@CodingNinja
CodingNinja / Manager.php
Created December 30, 2011 13:09
Grant / Revoke ACL Permissions
<?php
/*
* Copyright (C) 2011 David Mann
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is furnished to do
@fdemiramon
fdemiramon / pre-commit
Created May 12, 2015 19:13
Pre-commit hook for git with phpcs and phpcbf (auto-correct obvious violations)
#!/bin/sh
PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"`
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`
# Determine if a file list is passed
if [ "$#" -eq 1 ]
then
oIFS=$IFS
IFS='
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<application>
<meta-data
android:name="com.samsung.android.vr.application.mode"
android:value="vr_only"/>
</application>
</manifest>
@petercossey
petercossey / ubuntu-powerline-install.md
Last active July 12, 2022 12:44
Powerline font install for Ubuntu 16.10 (also confirmed working for 17.04, 17.10, 18.04, 19.10)

Install Powerline fonts for Z shell

Please note: there is an APT package called "fonts-powerline" which is tested and working for Ubuntu 20.04 which achieves the same outcome. Try "sudo apt install fonts-powerline"

If you're using Z Shell and a special prompt theme designed with Powerline fonts in mind, you'll need to install them on your machine. These are the most clear and cut-down instructions that I've found to work with Ubuntu 16.10 (also confirmed working for 17.04, 17.10, 18.04, 19.10) and all credit goes to renshuki's Ubuntu 14.04 + Terminator + Oh My ZSH with Agnoster Theme gist. I've extracted just the Powerline font instructions - my personal setup uses Prezto instead of Oh My ZSH (not included here).

Get the font and config files

cd ~
@evancz
evancz / Architecture.md
Last active December 21, 2022 14:28
Ideas and guidelines for architecting larger applications in Elm to be modular and extensible

Architecture in Elm

This document is a collection of concepts and strategies to make large Elm projects modular and extensible.

We will start by thinking about the structure of signals in our program. Broadly speaking, your application state should live in one big foldp. You will probably merge a bunch of input signals into a single stream of updates. This sounds a bit crazy at first, but it is in the same ballpark as Om or Facebook's Flux. There are a couple major benefits to having a centralized home for your application state:

  1. There is a single source of truth. Traditional approaches force you to write a decent amount of custom and error prone code to synchronize state between many different stateful components. (The state of this widget needs to be synced with the application state, which needs to be synced with some other widget, etc.) By placing all of your state in one location, you eliminate an entire class of bugs in which two components get into inconsistent states. We also think yo
@cpq
cpq / Hash.md
Created January 24, 2014 14:35
What is a hash and how does it work

What is a hash and how does it work

Let us start from a practical example. Imagine we are writing a traffic monitoring application. The purpose of application would be to calculate a number of bytes sent by each IP address. To do that, let create a structure that does that accounting:

struct ipstat {

uint32_t ip; /* Source IP address */