Skip to content

Instantly share code, notes, and snippets.

View nonsintetic's full-sized avatar

Octav Iosif nonsintetic

View GitHub Profile
@nonsintetic
nonsintetic / version_compare.js
Created June 2, 2022 10:51 — forked from TheDistantSea/version_compare.js
Function to compare two version strings (e.g. "1.6.1" is smaller than "1.7"). Developed in order to answer http://stackoverflow.com/a/6832721/50079.
/**
* Compares two software version numbers (e.g. "1.7.1" or "1.2b").
*
* This function was born in http://stackoverflow.com/a/6832721.
*
* @param {string} v1 The first version to be compared.
* @param {string} v2 The second version to be compared.
* @param {object} [options] Optional flags that affect comparison behavior:
* <ul>
* <li>
@nonsintetic
nonsintetic / struct_union.ino
Last active August 11, 2023 00:23
Arduino structures and unions
/* Arduino data manipulation and concatenation with structures and unions
*
* This simple (ish) sketch shows you how to organize your data into a struct
* and then access the whole thing as a byte array.
*
* Useful if you want to concatenate several variables into a single byte array
* to send over bluetooth, i2c, lora or any other protocol that works with arrays.
* In other words you have a fixed byte array, and we squeeze in variables of different
* data types and lengths into it, while still using it as a byte array afterwards.
*
@nonsintetic
nonsintetic / tronxy-pla-s3d.txt
Created July 10, 2017 10:06
TronXY X1 - Simplify3D generic settings for PLA
Extruder:
- Nozzle Diameter: 0.40mm
- Extrusion Multiplier: 1.00 (can fiddle with this: if you get holes in top layers - increase, if you get blobs and the head digs into the current layer - decrease)
- Extrusion Width: auto
- Retraction:
- Distance: 4-6mm or less even
- Extra Restart Dist: 0.5
- Vertical Lift: 0
- Retraction Speed: 3000
- Coast at end - enabled - 0.1mm
@nonsintetic
nonsintetic / RFM69HW_Serial.ino
Created March 22, 2017 17:14
RFM69HW with RFM69 library
// RFM69HCW Example Sketch
// Send serial input characters from one RFM69 node to another
// Based on RFM69 library sample code by Felix Rusu
// http://LowPowerLab.com/contact
// Modified for RFM69HCW by Mike Grusin, 4/16
// This sketch will show you the basics of using an
// RFM69HCW radio module. SparkFun's part numbers are:
// 915MHz: https://www.sparkfun.com/products/12775
// 434MHz: https://www.sparkfun.com/products/12823
@nonsintetic
nonsintetic / ArduinoZeroTimer.ino
Last active April 1, 2024 11:52
SAMD21 Arduino Timer Example
/*
* This sketch illustrates how to set a timer on an SAMD21 based board in Arduino (Feather M0, Arduino Zero should work)
* It should generate a 1Hz square wave as it is (thanks richdrich for the suggestion)
* Some more info about Timer Counter works can be found in this article:
* http://www.lucadavidian.com/2017/08/08/arduino-m0-pro-il-sistema-di-clock/
* and in the datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/SAM_D21_DA1_Family_DataSheet_DS40001882F.pdf
*/
uint32_t sampleRate = 1000; //sample rate in milliseconds, determines how often TC5_Handler is called
@nonsintetic
nonsintetic / readme.md
Last active January 19, 2024 10:57
PHP - Get YouTube subscriber count with Youtube API v3

How to:

Here's a 'simple' way to get the YouTube subscriber number from Google's Youtube API v3:

  1. Go to https://console.developers.google.com/apis/library
  2. Log in with your Google account.
  3. Next to the logo click on 'Project' and 'Create project'. Name it whatever you want and click on 'Create'.
  4. Wait until the project is created, the page will switch to it by itself, it will take a couple of seconds up to a minute. Once it's done it will be selected next to the logo.
  5. Once it's created and selected, click on 'Credentials' from the menu on the left.
  6. Click on 'Create Credentials' and choose 'API Key'. You can restrict it to specific IPs, or types of requests (website, android, ios etc.) if you want, it's safer that way.
@nonsintetic
nonsintetic / gist:9144e9a43d50a1ce90d6
Created November 27, 2015 13:19
create url slugs from romanian phrases (diacritics, punctuation and link words handling)
function slugify_romanian($input) {
$out = str_replace(array(
',',
':',
'”',
'.',
'"',
"'",
'!',
'?',
@nonsintetic
nonsintetic / fixoauth.php
Last active September 23, 2015 23:45
Fix for the WordPress plugin 'WP OAuth Server' to make it work with Rocket Chat's custom oAuth.
<?php
/*
This gist provides a fix for making the plugin WP oAuth Server work with
Rocket Chat's custom oAuth login.
Just require_once(file_name) this file in functions.php in your template
or just paste it at the end of it.
It's written for plugin version 3.1.7, but may work for newer ones as well.
Wordpress Plugin page: https://wordpress.org/plugins/oauth2-provider/ (made for v.3.1.7)
Rocket Chat: https://github.com/RocketChat/Rocket.Chat
More Details: https://github.com/RocketChat/Rocket.Chat/issues/747