Skip to content

Instantly share code, notes, and snippets.

View amrography's full-sized avatar
🚀
...

Amro Khaled amrography

🚀
...
View GitHub Profile
@stirtingale
stirtingale / instagram_id_to_url.php
Last active November 18, 2019 08:13
Simple PHP function to convert an Instagram ID into a URL.
// based on ggwarpig stackoverflow anwser to
// "Where do I find the Instagram media ID of a image"
// @ https://stackoverflow.com/a/37246231
function instagram_id_to_url($instagram_id){
$url_prefix = "https://www.instagram.com/p/";
if(!empty(strpos($instagram_id, '_'))){
@kellenmace
kellenmace / remove-duplicate-objects-from-array.php
Created February 2, 2019 16:21
If you have an indexed array of objects, and you want to remove duplicates by comparing a specific property in each object, a function like the remove_duplicate_models() one below can be used.
<?php
class Car {
private $model;
public function __construct( $model ) {
$this->model = $model;
}
public function get_model() {
@betweenbrain
betweenbrain / gist:2284129
Created April 2, 2012 14:56
Git command to export only changed files between two commits
git archive --output=file.zip HEAD $(git diff --name-only SHA1 SHA2)
@jeremycastelli
jeremycastelli / Storage.ts
Created October 27, 2020 10:42
vuex persist capacitor SQLite storage
import { Plugins } from '@capacitor/core';
import 'capacitor-data-storage-sqlite';
export function useStorage(options: any = {}) {
const { CapacitorDataStorageSqlite } = Plugins;
const storage: any = CapacitorDataStorageSqlite;
let opened = false;
const openStorage = async (): Promise<boolean> => {
@Amitesh
Amitesh / backup-to-git.sh
Created December 9, 2011 12:53 — forked from aarongustafson/backup-to-git.sh
DB Backup to Git
#!/bin/bash
##
# MySQL DB dump to Git commit
#
# Dumps the specified mysql database to the given location and commits it and
# the previous database to the Git repository.
#
# It is assumed you have already setup the Git respository to only be the
# a checkout of the database backup location
@naholyr
naholyr / compare.php
Created February 22, 2012 16:27
Extract namespace from a PHP file
<?php
// Works in every situations
function by_token ($src) {
$tokens = token_get_all($src);
$count = count($tokens);
$i = 0;
$namespace = '';
$namespace_ok = false;
while ($i < $count) {
<?php
###############################################################
# cPanel Subdomains Creator 1.1
###############################################################
# Visit http://www.zubrag.com/scripts/ for updates
###############################################################
#
# Can be used in 3 ways:
# 1. just open script in browser and fill the form
@vjt
vjt / 2fa
Last active May 12, 2023 11:28
2FA from the mac command line using oathtool-toolkit without much fuss
#!/bin/bash
# -*- 2fa Command Line -*-
#
# Uses oath-toolkit http://nongnu.org/oath-toolkit/
# to generate 2FA OTPs and copies them in the Mac's
# clipboard using pbcopy(1). For other UNIX systems
# you can just strip the pbcopy at the bottom.
#
# In the dir below you should put TOTP token seeds,
@Razoxane
Razoxane / laravel_conditional_index_migration.php
Created August 8, 2017 01:35
Laravel - Create Index If Not Exists / Drop Index If Exists
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class LaravelConditionalIndexMigration extends Migration
{
/**
* Run the migrations.
<?php
ini_set('pcre.backtrack_limit', '10000000');
$url = 'https://ru.tradingview.com/chart/VIX/veShLNLq-vix/'; // Ссылка на торговую идею trading view
$filename = dirname(__FILE__) . '/candles.json'; // Путь к файлу, в который будут сохранены свечи
$html = file_get_contents($url);
if (empty($html)) {