Skip to content

Instantly share code, notes, and snippets.

🎯
Focusing

Saleh Souzanchi zoghal

🎯
Focusing
Block or report user

Report or block zoghal

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@zoghal
zoghal / gist:06f9d8ffdbd82bbea4ce76e38a999d3b
Last active Jan 23, 2018 — forked from baghayi-gist/gist:4009084
PHP: Converting Numbers functions Persian To English & English To Persian
View gist:06f9d8ffdbd82bbea4ce76e38a999d3b
function convertNumbersFaToEn($number)
{
$persian = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹');
$num = range(0, 9);
return str_replace($persian, $num, $number);
}
function convertNumbersEnToFA($number)
{
$persian = array('۰', '۱', '۲', '۳', '۴', '۵', '۶', '۷', '۸', '۹');
$num = range(0, 9);
@zoghal
zoghal / debug.py
Created Oct 8, 2016 — forked from sah/debug.py
some handy functions for debugging python code
View debug.py
# Copyright © 2011, 2012, 2013, 2014 Sauce Labs Inc
#
# 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 so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
@zoghal
zoghal / nginx.conf
Created Oct 17, 2015 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
View nginx.conf
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@zoghal
zoghal / gsub.js
Last active Sep 6, 2015 — forked from geowarin/gsub.js
Javascript implementation of ruby gsub
View gsub.js
String.prototype.gsub = function (pattern, replacement) {
var match, result, source = this.toString();
if (pattern == null || replacement == null) {
return source;
}
result = '';
while (match = source.match(pattern)) {
result += source.slice(0, match.index);
result += typeof replacement === 'function' ? replacement(match[0]) : replacement;
source = source.slice(match.index + match[0].length);
@zoghal
zoghal / JS gsub
Last active Aug 29, 2015 — forked from varunkumar/JS gsub
JavaScript implementaion of ruby's gsub
View JS gsub
gsub = function(source, pattern, replacement) {
var match, result;
if (!((pattern != null) && (replacement != null))) {
return source;
}
result = '';
while (source.length > 0) {
if ((match = source.match(pattern))) {
result += source.slice(0, match.index);
result += (typeof replacement === 'function') ? replacement(match[0]) : replacement;
View test.js
var Ghost = require('webghost');
var should = require('should');
var ghost = new Ghost({browser: "chrome", host: "ip"});
ghost.open()
.go("http://your/url")
.text('p', function (text) {
text.should.be.not.equal('haha');
})
.click('button') // 点击按钮
View ghost_capture_pdf.py
from ghost import Ghost
from PySide.QtGui import QApplication, QImage, QPainter, QPrinter
class MyGhost(Ghost):
def capture_pdf(self):
printer = QPrinter(QPrinter.HighResolution)
printer.setResolution(300)
printer.setOutputFileName("QtPrinter.pdf")
printer.setPaperSize(QPrinter.A4)
View gist:ced47502fed1dc7d0397
from ghost import Ghost
from sys import argv
def main():
url = argv[1]
path = argv[2]
screenshot(url,path)
def screenshot(url,path):
ghost = Ghost()
View responsiveCheck.py
# Installation:
# pip install selenium && curl -O http://chromedriver.storage.googleapis.com/2.8/chromedriver_mac32.zip && unzip chromedriver_mac32.zip && mv ./chromedriver /usr/local/bin/chromedriver
# Resources:
# ChromeDriver: https://code.google.com/p/selenium/wiki/ChromeDriver
# ChromeDriver Getting Started: https://sites.google.com/a/chromium.org/chromedriver/getting-started
# Selenium Python: http://selenium-python.readthedocs.org/en/latest/api.html
from selenium import webdriver
View gist:65a62033de593b98e774
from ghost import Ghost
from sys import argv
def main():
url = argv[1]
path = argv[2]
screenshot(url,path)
def screenshot(url,path):
ghost = Ghost()
You can’t perform that action at this time.