Skip to content

Instantly share code, notes, and snippets.

View nilesolutions's full-sized avatar

Ahmed Samy nilesolutions

  • Abu dhabi
View GitHub Profile
@nilesolutions
nilesolutions / mytop.sh
Created September 9, 2018 07:32 — forked from detain/mytop.sh
mytop (Monitor mysql process list with top like screen updates and adiditonal stats like cpu/io usage)
#!/bin/bash
# mytop.sh - (Monitor mysql process list with top like screen updates and adiditonal stats like cpu/io usage)
#
# Sample Output:
#
# CPU Usage 3.29% user 1.60% system 3.37% io wait 0.00% steal 91.59% idle
# Up 17 days 10 hours Load Avg 0.43 0.36 0.35 Processes 1(running) 408(total) Last PID 17825
# +----------+------+-----------+----+---------+------+-------+------------------+
# | Id | User | Host | db | Command | Time | State | Info |
# +----------+------+-----------+----+---------+------+-------+------------------+
@nilesolutions
nilesolutions / reteet_lambda.js
Created July 13, 2018 11:07 — forked from tanish-kr/reteet_lambda.js
twitter get retweet by lambda function
'use strict';
const AWS = require("aws-sdk");
const dynamodb = new AWS.DynamoDB();
const querystring = require("querystring");
const http = require("https");
const TWITTER_API_URL = "https://api.twitter.com"
const TWITTER_HOSTNAME = "api.twitter.com"
/**
@nilesolutions
nilesolutions / Dockerfile
Created June 22, 2018 19:06 — forked from hardillb/Dockerfile
Mosquitto + auth_plugin + mongo
FROM ubuntu:16.04
MAINTAINER Ben Hardill <[email protected]>
ENV DEBIAN_FRONTEND noninteractive
USER root
RUN apt-get update && apt-get install -y \
pkg-config \
@nilesolutions
nilesolutions / README.md
Created April 2, 2018 12:09 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@nilesolutions
nilesolutions / DemoReel100.ino
Created January 19, 2018 09:44 — forked from kriegsman/DemoReel100.ino
FastLED "100-line" demo reel
#include "FastLED.h"
// FastLED "100-lines-of-code" demo reel, showing just a few
// of the kinds of animation patterns you can quickly and easily
// compose using FastLED.
//
// This example also shows one easy way to define multiple
// animations patterns and have them automatically rotate.
//
// -Mark Kriegsman, December 2014
@nilesolutions
nilesolutions / CompressAwsImages.php
Created December 29, 2017 21:02 — forked from Ryuske/CompressAwsImages.php
Laravel 4.2 artisan command for compressing AWS images
<?php
/**
* Command for losslessly compressing Amazon AWS images
*/
use Illuminate\Console\Command;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
/**
<?php
function compose(callable $initial, callable ...$functions)
{
if (count($functions) < 1) {
throw new \InvalidArgumentException('at least two functions are required');
}
return array_reduce($functions, function ($f, $g) {
return function (...$args) use ($f, $g) {
return $f($g(...$args));
@nilesolutions
nilesolutions / tokener.php
Created December 23, 2017 14:44
secrets sharing via token
<?php
require 'vendor/autoload.php';
function decrypt($secret, $string)
{
try {
Firebase\JWT\JWT::$leeway = 1; // $leeway in seconds is a clock skew times between the signing and verifying servers
$string = base64_decode($string);
return (array) Firebase\JWT\JWT::decode(
openssl_decrypt(
@nilesolutions
nilesolutions / wp_remove_p_around_img.php
Created December 23, 2017 12:20 — forked from vinicio/wp_remove_p_around_img.php
Remove paragraph tags around images in WordPress post/page content
<?php
/**
* Move image inside <p> tag above the <p> tag while preserving any link around image.
* Can be prevented by adding any attribute or whitespace to <p> tag, e.g. <p class="yolo"> or even <p >
*/
function remove_p_around_img($content)
{
$contentWithFixedPTags = preg_replace_callback('/<p>((?:.(?!p>))*?)(<a[^>]*>)?\s*(<img[^>]+>)(<\/a>)?(.*?)<\/p>/is', function($matches) {
$image = $matches[2] . $matches[3] . $matches[4];
@nilesolutions
nilesolutions / pars_category.php
Created December 23, 2017 11:45 — forked from ig0r74/pars_category.php
Парсер сайта на примере poverka-ndt.ru
<?php
print '<pre>';
class parserXPath extends DOMXPath {
private function getPage($url){
$ch = curl_init();
curl_setopt ($ch , CURLOPT_URL , $url);
curl_setopt ($ch , CURLOPT_USERAGENT , "Mozilla/5.0");
curl_setopt ($ch , CURLOPT_RETURNTRANSFER , 1 );
// можете добавить кучу других опций