Skip to content

Instantly share code, notes, and snippets.

@vordan
vordan / build_tree.php
Last active February 5, 2023 09:13 — forked from ziishaned/output.json
Build a tree from a flat array in PHP
<?php
//--------------------------------------------------------
// Example:
//
// $cars = [
// ['id' => 999, 'value' =>'CARS', 'parent_id' => 0 ],
// ['id' => 11, 'value' =>'Toyota', 'parent_id' => 999],
// ['id' => 1, 'value' =>'Avalon', 'parent_id' => 11 ],
// ['id' => 2, 'value' =>'Corolla', 'parent_id' => 11 ],
// ['id' => 3, 'value' =>'Camry', 'parent_id' => 11 ],
@szihaj
szihaj / install_php5.3_on_ubuntu.txt
Last active September 20, 2023 15:09
How to install PHP 5.3 on Ubuntu
sudo add-apt-repository ppa:sergey-dryabzhinsky/php53
sudo apt-get update
sudo apt-get install php53-common php53-cli
# to see a list of available packages:
# apt-cache search php53
# ex.: sudo apt-get install php53-mod-mysql
# Apache module:
sudo apt-get install libapache2-mod-php53
@usmcamp0811
usmcamp0811 / datatables.js
Created August 1, 2018 17:31
Custome PDF in DataTables Example
$(document).ready(function() {
// Function to convert an img URL to data URL
function getBase64FromImageUrl(url) {
var img = new Image();
img.crossOrigin = "anonymous";
img.onload = function () {
var canvas = document.createElement("canvas");
canvas.width =this.width;
canvas.height =this.height;
var ctx = canvas.getContext("2d");
@BenoitAverty
BenoitAverty / userChrome.css
Last active July 22, 2023 13:32
Hide tab bar on firefox 89 when there is only one tab
/*
How To:
1. Find your firefox profile folder : https://support.mozilla.org/en-US/kb/profiles-where-firefox-stores-user-data
2. create a "chrome" folder if it doesn't exist
3. Paste content of this gist in a "userChrome.css" file
4. Go to about:config and set toolkit.legacyUserProfileCustomizations.stylesheets to true
5. set browser.tabs.tabmanager.enabled to false (to hide the "tab search" button)
5. Restart Firefox
Don't hesitate to say if there are bugs, I only tested this for my workflow : I don't use tabs
@developit
developit / async-examples.js
Last active February 19, 2020 00:43
Async Array utilities in async/await. Now available as an npm package: https://github.com/developit/asyncro
/** Async version of Array.prototype.reduce()
* await reduce(['/foo', '/bar', '/baz'], async (acc, v) => {
* acc[v] = await (await fetch(v)).json();
* return acc;
* }, {});
*/
export async function reduce(arr, fn, val, pure) {
for (let i=0; i<arr.length; i++) {
let v = await fn(val, arr[i], i, arr);
if (pure!==false) val = v;
@statickidz
statickidz / nearby-coordinates.sql
Last active January 31, 2024 20:31
Ordering with SQL by nearest latitude & longitude coordinates (MySQL & SQLite)
---
METHOD 1
This should roughly sort the items on distance in MySQL, and should work in SQLite.
If you need to sort them preciser, you could try using the Pythagorean theorem (a^2 + b^2 = c^2) to get the exact distance.
---
SELECT *
FROM table
ORDER BY ((lat-$user_lat)*(lat-$user_lat)) + ((lng - $user_lng)*(lng - $user_lng)) ASC
@alfredobarron
alfredobarron / select2-bootstrap3.css
Created August 19, 2015 21:55
Height select 2 in bootstrap 3.3.4
/**
* Change three lines
*
/* line 11 */
.select2-container .select2-selection--single {
box-sizing: border-box;
cursor: pointer;
display: block;
height: 34px;
user-select: none;
@chrissimpkins
chrissimpkins / gist:5bf5686bae86b8129bee
Last active June 19, 2024 18:05
Atom Editor Cheat Sheet: macOS

Use these rapid keyboard shortcuts to control the GitHub Atom text editor on macOS.

Key to the Keys

  • ⌘ : Command key
  • ⌃ : Control key
  • ⌫ : Delete key
  • ← : Left arrow key
  • → : Right arrow key
  • ↑ : Up arrow key
@ericelliott
ericelliott / essential-javascript-links.md
Last active July 18, 2024 15:03
Essential JavaScript Links
@dconnolly
dconnolly / README.md
Last active June 7, 2024 07:42
All 100 Chromecast background images that are rotated through, linked to their original locations on Google hosting. Links to 2560 width versions, where available.