Skip to content

Instantly share code, notes, and snippets.

View bastibeckr's full-sized avatar

Basti Becker bastibeckr

  • studio2010 GmbH
  • Munich, Germany
  • 06:02 (UTC +02:00)
View GitHub Profile
@RadGH
RadGH / get-video-oembed-wordpress.php
Last active October 3, 2022 01:03
Get oEmbed data using WordPress oEmbed API, specifically for Video iframe
<?php
// Example 1) Using a function. Returns an array.
function radgh_get_video_data( $url, $width = null, $height = null ) {
if ( function_exists('_wp_oembed_get_object') ) {
require_once( ABSPATH . WPINC . '/class-oembed.php' );
}
$args = array();
if ( $width ) $args['width'] = $width;
if ( $height ) $args['height'] = $height;
@andreilupu
andreilupu / tinymce.plugin.example.js
Last active January 10, 2024 11:09
TinyMCE Plugin Example
(function () {
/**
* A TinyMCE plugin example and some events handlings.
*/
tinymce.PluginManager.add('gridable', function ( editor, url ) {
// if your plugin needs a toolbar, save it for a larger scope
var toolbar;
/**
@ethaizone
ethaizone / server_time_sync.js
Last active December 21, 2024 11:43
Sync server time to client browser with JS. Implement follow Network Time Protocol.
// Original from http://stackoverflow.com/questions/1638337/the-best-way-to-synchronize-client-side-javascript-clock-with-server-date
// Improved by community and @jskowron
// Synchronize client-side clock with server time using an approximation of NTP
let serverTimeOffset = null;
function getServerTime(callback) {
if (serverTimeOffset === null) {
const scripts = document.getElementsByTagName("script");
const currentScriptURL = scripts[scripts.length - 1].src;
@soderlind
soderlind / dropzonejs-wp-rest-api-custom-endpoint.js
Created February 1, 2016 19:33
DropzoneJS & WordPress REST API with Custom Endpoint
// dropzoneWordpressRestApiForm is the configuration for the element that has an id attribute
// with the value dropzone-wordpress-rest-api-form (or dropzoneWordpressRestApiForm)
Dropzone.options.dropzoneWordpressRestApiForm = {
//acceptedFiles: "image/*", // all image mime types
acceptedFiles: ".jpg", // only .jpg files
maxFiles: 1,
uploadMultiple: false,
maxFilesize: 5, // 5 MB
init: function() {
console.group('dropzonejs-wp-rest-api:');
@jjnilton
jjnilton / mac-network-commands-cheat-sheet.md
Last active May 30, 2025 04:11
Mac Network Commands Cheat Sheet

Disclaimer: I'm not the original author of this sheet, but can't recall where I found it. If you know the author, please let me know so I give the attribution.

The original author seems to be Charles Edge, here's the original content, as pointed out by @percisely.

Note: Since this seems to be helpful to some people, I formatted it to improve readability of the original. Also, note that this is from 2016, many things may have changed, and I don't use macOS anymore, so I probably can't help in case of questions, but maybe someone else can.

Mac Network Commands Cheat Sheet

After writing up the presentation for MacSysAdmin in Sweden, I decided to go ahead and throw these into a quick cheat sheet for anyone who’d like to have them all in one place. Good luck out there, and s

@pmbuko
pmbuko / ad_pass_exp.sh
Last active November 27, 2017 21:27
These are the shell commands that ADPassMon uses internally to get the information it needs.
#!/bin/bash
myDomain=$(dsconfigad -show | awk '/Active Directory Domain/{print $NF}')
myLDAP=$(dig -t srv _ldap._tcp.${myDomain} | awk '/^_ldap/{print $NF}' | head -1)
mySearchBase=$(ldapsearch -LLL -Q -s base -H ldap://${myLDAP} defaultNamingContext | awk '/defaultNamingContext/{print $2}')
uAC=$(dscl localhost read /Search/Users/$USER userAccountControl | awk '/:userAccountControl:/{print $2}')
if [[ $uAC =~ ^6 ]]; then
@toddtreece
toddtreece / midi_cv.ino
Created April 28, 2015 02:33
FifteenStep: MIDI in -> CV Out
// ---------------------------------------------------------------------------
//
// midi_cv.ino
//
// A MIDI sequencer example using two MCP4725 dacs for eurorack control voltage
// output and NeoPixels for display.
//
// Required dependencies:
// Adafruit FifteenStep Sequencer Library: https://github.com/adafruit/FifteenStep
// Adafruit NeoPixel Library: https://github.com/adafruit/Adafruit_NeoPixel
@drkarl
drkarl / gist:739a864b3275e901d317
Last active April 29, 2025 20:18
Ask HN: Best Linux server backup system?

Linux Backup Solutions

I've been looking for the best Linux backup system, and also reading lots of HN comments.

Instead of putting pros and cons of every backup system I'll just list some deal-breakers which would disqualify them.

Also I would like that you, the HN community, would add more deal breakers for these or other backup systems if you know some more and at the same time, if you have data to disprove some of the deal-breakers listed here (benchmarks, info about something being true for older releases but is fixed on newer releases), please share it so that I can edit this list accordingly.

  • It has a lot of management overhead and that's a problem if you don't have time for a full time backup administrator.
@tracker1
tracker1 / 01-directory-structure.md
Last active May 3, 2025 04:36
Anatomy of a JavaScript/Node project.

Directory structure for JavaScript/Node Projects

While the following structure is not an absolute requirement or enforced by the tools, it is a recommendation based on what the JavaScript and in particular Node community at large have been following by convention.

Beyond a suggested structure, no tooling recommendations, or sub-module structure is outlined here.

Directories

  • lib/ is intended for code that can run as-is
  • src/ is intended for code that needs to be manipulated before it can be used
@amatiasq
amatiasq / throttle-promise.js
Last active November 16, 2018 16:20
This function will prevent a long operation to be executed twice in parallel. If the function is invoked a second time before the first time has completed it will receive the same promise from the first invocation without need to invoke the operation again.
function throttlePromise(operation) {
var promise = null;
return function() {
if (!promise) {
promise = operation.apply(this, arguments).finally(function() {
promise = null;
});
}