Skip to content

Instantly share code, notes, and snippets.

View HazemNoor's full-sized avatar
🧐
Clarity is better than cleverness.

Hazem Noor HazemNoor

🧐
Clarity is better than cleverness.
View GitHub Profile
package main
import "golang.org/x/tour/pic"
func Pic(dx, dy int) [][]uint8 {
ret := make([][]uint8, dy)
for y := 0; y < dy; y++ {
row := make([]uint8, dx)
for x := 0; x < dx; x++ {
row[x] = uint8(y)
<html>
<body>
<canvas width="800" height="800" id="c" />
<script type="text/javascript">
function doit(){
function wpex_minify_css( $css ) {
// Normalize whitespace
$css = preg_replace( '/\s+/', ' ', $css );
// Remove ; before }
$css = preg_replace( '/;(?=\s*})/', '', $css );
// Remove space after , : ; { } */ >
$css = preg_replace( '/(,|:|;|\{|}|\*\/|>) /', '$1', $css );
@skyrepprac
skyrepprac / gist:fe781b30e53f5e2aca99ff7e65013c37
Created July 12, 2017 06:16
Magento - Add Bundle Product Programmatically
<?php
require_once('includes/config.php');
require_once('app/Mage.php');
$storeID = 1;
$websiteIDs = array(1);
$cats = array(5);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
@maxivak
maxivak / __upload_file.md
Last active January 30, 2025 19:11
PHP upload file with curl (multipart/form-data)

We want to upload file to a server with POST HTTP request. We will use curl functions.


// data fields for POST request
$fields = array("f1"=>"value1", "another_field2"=>"anothervalue");

// files to upload
$filenames = array("/tmp/1.jpg", "/tmp/2.png");
@pablorsk
pablorsk / CorsMiddleware.php
Last active August 15, 2020 20:23
CORS middleware for Lumen and PSR-7
<?php
namespace App\Http\Middleware;
use Closure;
class CorsMiddleware
{
/**
* Handle an incoming request.
@sliceofbytes
sliceofbytes / txt-to-google-keep-notes.py
Created February 14, 2018 22:16
Add Text Files as Google Keep Notes
#Import a directory of text files as google keep notes.
#Text Filename is used for the title of the note.
import gkeepapi, os
username = '[email protected]'
password = 'your app password'
keep = gkeepapi.Keep()
success = keep.login(username,password)
@AhmedKamal20
AhmedKamal20 / subl_last_commit.sh
Created February 24, 2018 01:49
Open all modified files of the last commit with Sublime Text
git diff-tree --no-commit-id --name-only -r HEAD | xargs subl
@bittercoder
bittercoder / convert.sh
Last active December 4, 2024 17:25
Convert .heic files to .jpg on linux (coming from an iOS11 device over USB)
# download release from github: https://github.com/monostream/tifig/releases and install at ~/tools/tifig
# then run these commands in the folder (just to keep things simple we normalize the file extension case before proceeding).
for f in *.HEIC; do mv "$f" "`echo $f | sed s/.HEIC/.heic/`"; done
for file in *.heic; do echo "~/tools/tifig -v -p $file ${file/%.heic/.jpg}"; done
@Pierstoval
Pierstoval / _PHP is_a() vs is_subclass_of().md
Last active September 7, 2025 00:55
`is_a()` vs `is_subclass_of()`

PHP is_a() vs is_subclass_of()

<?php

class A {}

class B extends A {}