Skip to content

Instantly share code, notes, and snippets.

View itshaadi's full-sized avatar

Hadi Azami itshaadi

View GitHub Profile
@itshaadi
itshaadi / imdbi-example1.php
Last active June 19, 2016 14:51
imdbi_check Example
<?php
if(imdbi_check('actors')){
echo imdbi('actors');
}
else{
echo get_post_meta($post->ID, 'my_field_actors', true);
}
?>
@itshaadi
itshaadi / imdbi-example2.php
Last active June 19, 2016 15:38
imdbi function and shortcode
<?php
// چاپ رقم مربوط به بودجه
echo imdbi('budget');
// ساختن یک تگ تصویر و نمایش پوستر
$poster = imdbi('poster');
$html = '<img src='.$poster.' alt='.the_title().'>';
echo $html;
?>
<?php
if(imdbi_check('rank')){
echo "این فیلم دارای رتبه".imdbi('rank')."می باشد."
}
?>
@itshaadi
itshaadi / subfixer.sh
Last active March 27, 2021 11:58
this script will change the encoding from whatever to UTF-8
#!/bin/bash
#you may need to install uchardet package first. sudo apt install uchardet
# https://github.com/BYVoid/uchardet
#replace underscore with white-space !important (iconv cannot find files with white-space in their name)
find -name "* *.srt" -type f | rename 's/ /_/g'
for sub in *.srt;
do
encode="$(uchardet "${sub}")"
@itshaadi
itshaadi / installation.sh
Created September 21, 2016 10:25
I have prepared the following shell script to make LAMP installation fully automated.
#!/bin/bash
if [ "`lsb_release -is`" == "Ubuntu" ] || [ "`lsb_release -is`" == "Debian" ]
then
sudo apt-get -y install mysql-server mysql-client mysql-workbench libmysqld-dev;
sudo apt-get -y install apache2 php5 libapache2-mod-php5 php5-mcrypt phpmyadmin;
sudo chmod 777 -R /var/www/;
sudo printf "<?php\nphpinfo();\n?>" > /var/www/html/info.php;
sudo service apache2 restart;
else
@itshaadi
itshaadi / clipboard.py
Last active October 7, 2016 19:35
increase clipboard memory with python
# When Ctrl+C is pressed, this script will add the current value of
# clipboard into a stack (deque) and when Shift+Alt+V is pressed
# it will pop the leftmost value and paste it on the screen
# until stack is empty
import gi
gi.require_version('Gtk', '3.0')
gi.require_version('Gdk', '3.0')
from keybinder.keybinder_gtk import KeybinderGtk #https://github.com/LiuLang/python3-keybinder
from pykeyboard import PyKeyboard #https://github.com/PyUserInput/PyUserInput
@itshaadi
itshaadi / subfixer.cs
Created February 14, 2017 16:06
fixing weird subtitles with c sharp.
using System;
using System.Text;
using System.Collections.Specialized;
using System.IO;
using Ude;
public static void ConvertFileEncoding(String sourcePath, String destPath, Encoding sourceEncoding, Encoding destEncoding)
{
@itshaadi
itshaadi / Main.cs
Created May 1, 2017 16:48
workaround for drag and drop in CefSharp (winfrom)
using System.Collections.Generic;
using Gma.System.MouseKeyHook; // for simulating OnDragDrop https://github.com/gmamaladze/globalmousekeyhook
using System.Windows.Forms;
using CefSharp;
public partial class MainForm : Form
{
private IList<string> dropFiles;
private ChromiumWebBrowser Browser;
@itshaadi
itshaadi / lamp.sh
Last active June 24, 2017 23:06
lamp stack with php7 for ubuntu/xenial on vagrant
#!/bin/bash
sudo -s
apt update -y
#Install apache2
apt install apache2 -y
#Suppress Syntax Warnings
@itshaadi
itshaadi / scandir.js
Created July 1, 2017 14:03
list all files in a recursive way
module.exports = function scandir (dir, cb) {
const fs = require('fs')
const path = require('path')
let result = []
fs.readdir(dir, (err, filesList) => {
if (err) return cb(err)
let pending = filesList.length
if (!pending) return cb(null, result)