Skip to content

Instantly share code, notes, and snippets.

View sanusart's full-sized avatar

Sasha Khamkov sanusart

View GitHub Profile
@sanusart
sanusart / index.html
Last active July 28, 2019 19:00
Tests of embed code - Can also be opened with Plunker if really, really, really, really, really, really, really, really, really, really, really, really needed really, really, really, really, really, really, really needed #long #test #gist
<script src="https://gist.github.com/sanusart/5944686.js"></script>
@sanusart
sanusart / functions.php
Last active November 3, 2018 17:25
Wordpress temp page for not logged-in users #wordpress
<?php
// functions.php
function temp_mode() {
if ( ! current_user_can( 'edit_themes' ) || ! is_user_logged_in() ) {
echo '<!DOCTYPE html>
<html>
<head>
<title>coming soon</title>
@sanusart
sanusart / filter.js
Last active October 29, 2017 04:36
AngularJS join by character #AngularJS #javascript #angular1
angular.module('App.filters', [])
.filter('joinBy', function () {
return function (input,delimiter) {
return (input || []).join(delimiter || ',');
};
});
@sanusart
sanusart / .htaccess
Created April 2, 2014 13:56
Block access to .git directory in document root #htaccess
RewriteEngine on
RewriteRule .*\.git/.* - [F]
@sanusart
sanusart / 01.configure
Last active October 6, 2018 20:08 — forked from hanxue/01.configure
gist with files more than 1M of size #big
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /usr/bin/clang accepts -g... yes
checking for /usr/bin/clang option to accept ISO C89... none needed
checking whether we are using the GNU C++ compiler... yes
checking whether /usr/bin/clang++ accepts -g... yes
@sanusart
sanusart / app.js
Created June 26, 2014 16:20
AngularJS base snippets #Angular
// Routing
angular.module('myAppName', [])
.config(function($routeProvider) {
$routeProvider
.when('/', {
templateUrl: 'views/home.html',
controller: 'homeCtrl'
})
.when('/inner', {
templateUrl: 'views/inner.html',
@sanusart
sanusart / .htaccess
Created July 12, 2014 05:57
Block access to specific file types by extension #htaccess #security #apache
<Files ~ "\.(js|sql)$">
order deny,allow
deny from all
</Files>
@sanusart
sanusart / snippets.md
Last active August 29, 2015 14:16
shell snippets and functions #shell #bash #sh

Inform with message

Use: message "Informing you about something"

message () {
    printf "\n";
    printf "\e[30;48;5;82m ${1} \e[0m "
    printf "\n";
}
@sanusart
sanusart / shell_json_parse.sh
Created March 4, 2015 08:42
shell get json value by key
#!/usr/bin/env bash
# --- Usage: `./shell_json_parse.sh /path/to/package.json version`
get_value_by_key() {
JSON_FILE=${1}
KEY=${2}
REGEX="(?<=\"${KEY}\":.\")[^\"]*"
JSON_VALUE=$(cat ${JSON_FILE} | grep -Po ${REGEX})
@sanusart
sanusart / execute-in-shell.sh
Created March 15, 2015 21:24
git remove file/dir from history #git
git filter-branch --force --prune-empty --index-filter 'git rm -rf --cached --ignore-unmatch DIR-OR-FILE' --tag-name-filter cat -- --all