Skip to content

Instantly share code, notes, and snippets.

View Benjaminhu's full-sized avatar
🚀
To infinity and beyond.

Simon Benjámin Benjaminhu

🚀
To infinity and beyond.
View GitHub Profile
@lsloan
lsloan / Copy Bitbucket repo to GitHub.md
Last active September 19, 2025 13:42 — forked from mandiwise/Update remote repo
Copy Bitbucket repo to GitHub

Copy Bitbucket repo to GitHub

Whenever possible, use GH's "Import repository" feature.

The import feature doesn't always work, though. In my experience, I tried to import a repo and it failed with a generic message. I had to contact GH support to ask for help. They told me my repo had a large file (>100MB), which couldn't be added to GH directly. I had to either remove the file or store it in GH LFS. In this case, one of the CLI methods below are needed:

CLI: Copy the master branch only (OK)

@zplume
zplume / MutationObserverVsDOMSubtreeModified.js
Created November 6, 2017 11:06
MutationObserver vs DOMSubtreeModified example which allows detecting changes in elements that don't exist yet, by detecting changes in a parent element that does exist at the time the function is executed.
// This example depends on jQuery().on and _.debounce
// Create a MutationObserver to trigger a callback function
// when the element located via document.querySelector(elementSelector) changes
function getMutationObserver(elementSelector, callback) {
var observer = new MutationObserver(callback);
var config = { attributes: true, childList: true, characterData: false };
observer.observe(document.querySelector(elementSelector), config);
return observer;
@Yousha
Yousha / .gitattributes
Last active March 8, 2023 11:17
.gitattributes for PHP developers.
* text=auto
###### Git
.gitattributes text
.gitignore text
.gitconfig text
.gitmodules text
##### Windows
*.bat text eol=crlf
@anvk
anvk / psql_useful_stat_queries.sql
Last active June 1, 2025 16:17
List of some useful Stat Queries for PSQL
--- PSQL queries which also duplicated from https://github.com/anvk/AwesomePSQLList/blob/master/README.md
--- some of them taken from https://www.slideshare.net/alexeylesovsky/deep-dive-into-postgresql-statistics-54594192
-- I'm not an expert in PSQL. Just a developer who is trying to accumulate useful stat queries which could potentially explain problems in your Postgres DB.
------------
-- Basics --
------------
-- Get indexes of tables
@vinsim24
vinsim24 / findExamples.sh
Created September 23, 2017 18:50
Bash Find Examples
#!/bin/bash
#Find all link files
ls -ltr `find . -maxdepth 1 -type l -print`
#Find and remove all files whose modified time is greater than 30 days
find . -type f -mtime +30 -exec rm {} \;
#Find particular word across files in same directory
find . -type f | xargs grep -l "searched_word"
#!/bin/bash
# variables
LOGFILE="/var/log/nginx/access.log"
LOGFILE_GZ="/var/log/nginx/access.log.*"
RESPONSE_CODE="200"
# functions
filters(){
grep $RESPONSE_CODE \
@leMaur
leMaur / LocalizeDatetime.php
Last active November 14, 2024 16:41
Middleware that extends Mcamara\Laravel-localization package functionalities. Set the locale LC_TIME for Carbon\Carbon to set the correctly datetime for each selected language. See comment for further details.
<?php
namespace App\Http\Middleware;
use Closure;
use Carbon\Carbon;
use Mcamara\LaravelLocalization\Middleware\LaravelLocalizationMiddlewareBase;
class LocalizeDatetime extends LaravelLocalizationMiddlewareBase
{
@dankrause
dankrause / postgresql_recursive.sql
Last active August 31, 2025 18:16
An example of creating a recursive postgresql query to generate data about parent-child relationships within a single table.
CREATE TABLE test
(
id INTEGER,
parent INTEGER
);
INSERT INTO test (id, parent) VALUES
(1, NULL),
(2, 1),
@mikoim
mikoim / README.md
Last active October 2, 2025 02:55
[Updated! Aug 14 2020] YouTube recommended encoding settings on ffmpeg (+ libx264)

Parameters

Container: MP4

Parameter YouTube recommends setting
-movflags faststart moov atom at the front of the file (Fast Start)

Video codec: H.264

@SimonEast
SimonEast / Acceptance.php
Last active March 11, 2021 15:07
Codeception - how to test for redirects
<?php
// Simply place the following two functions in _support/Helper/Acceptance.php
// Then you can call $I->verifyRedirect(...) inside your tests
namespace Helper;
class Acceptance extends \Codeception\Module
{
/**
* Ensure that a particular URL does NOT contain a 301/302