Skip to content

Instantly share code, notes, and snippets.

View rsoury's full-sized avatar
🍓
Foraging Berries

Ryan Soury rsoury

🍓
Foraging Berries
View GitHub Profile
@rsoury
rsoury / incrementUrlFriendlyString.js
Last active May 14, 2016 10:53
This function allows you to pass in a string, and it will increment it in a URL friendly manner. It can be useful for link shorteners, new chat string identifiers, etc.
function incUrlString(str){
var singles = str.split('');
var incNext = false;
var extendIt = false;
for(var i = singles.length - 1; i > -1; i --){
if(incNext || i == singles.length - 1){
incNext = false;
var ascii = singles[i].charCodeAt(0);
if(ascii == 57){
ascii = 65;
@rsoury
rsoury / incHash.js
Created June 3, 2016 16:05
Increment your hash without characters that directory names don't like.
const incHash = (str) => {
const singles = str.split('');
let incNext = false;
let extendIt = false;
for(let i = singles.length - 1; i > -1; i --){
if(incNext || i == singles.length - 1){
incNext = false;
let ascii = singles[i].charCodeAt(0);
if(ascii == 57){
ascii = 65;
@rsoury
rsoury / htmlinjector.js
Last active August 10, 2016 05:35
Node Code Injection for HTML5/FTP website. Requires Backup of original for resets. Made for ZipMoney.
import fs from 'fs';
import finder from 'fs-finder';
import cheerio from 'cheerio';
import colors from 'colors';
import S from 'string';
//To refresh target folder, rm -rf target, mkdir target, cp -a backup/. target
// npm Script: "reset": "rm -rf target && mkdir target && cp -a backup/. target" -> npm run reset
console.log('Starting node Widgeter Script...'.green);
@rsoury
rsoury / salesforce_sales_referral.html
Last active November 29, 2016 05:53
Referral Link For Sales Force Web To Lead
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/js-cookie/2.1.3/js.cookie.min.js"></script>
<script type="text/javascript">
(function($){
var getParameterByName = function(name, url) {
if (!url) {
url = window.location.href;
}
name = name.replace(/[\[\]]/g, "\\$&");
var regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
@rsoury
rsoury / getVideoId.js
Last active April 2, 2017 14:45
Get Video Id - Youtube, Vimeo, Vine, VideoPress
/**
* Get the vimeo id.
* @param {string} str - the url from which you want to extract the id
* @returns {string|undefined}
*/
function vimeo(str) {
if (str.indexOf('#') > -1) {
str = str.split('#')[0];
}
var id;
@rsoury
rsoury / ryan-sublime-bindings.json
Created September 4, 2017 01:03
Sublime Bindings
[
{ "keys": ["super+shift+o"], "command": "prompt_add_folder" },
{ "keys": ["/"], "command": "close_tag", "args": { "insert_slash": true }, "context":
[
{ "key": "selector", "operator": "equal", "operand": "(text.html, text.xml, meta.jsx.js) - string - comment", "match_all": true },
{ "key": "preceding_text", "operator": "regex_match", "operand": ".*<$", "match_all": true },
{ "key": "setting.auto_close_tags" }
]
},
{"keys": ["alt+shift+f"], "command": "reindent", "args": {"single_line": false}}
@rsoury
rsoury / async-js-lib-load.js
Created December 5, 2017 01:15
Async JS Lib Load
(function(window, document){
var load = function(){
var script = document.createElement('script');
script.async = true;
script.type = 'text/javascript';
script.src = 'THE_SOURCE_OF_JS_LIB_HERE.js';
var firstScript = document.getElementsByTagName('script')[0];
firstScript.parentNode.insertBefore(script, firstScript);
};
if(document.readyState === "complete"){
@rsoury
rsoury / wordpress-db-shortcode.php
Created October 24, 2018 04:30
Wordpress shortcode to Access DB Items
function your_shortcode_function( $atts ){
// $atts in case you want to receive attributes
// This lets you set default results for attributes that aren't provided.
$attributes = shortcode_atts(array(
"text" => "some text",
"link" => "Some link"
), $atts);
@rsoury
rsoury / smart-react-frame-component.jsx
Last active February 7, 2020 01:34
React Frame Component + IFrame Resizer -- Resizing outside of React preventing re-rendering on resize. Good for wrapping providers (or wrapping an entire react app) in an IFrame to prevent style inheritance. Works with Create React App.
import React, { useEffect } from "react";
import Frame, { FrameContextConsumer } from "react-frame-component";
import { iframeResize } from "iframe-resizer";
import iFrameResizeContentWindowScript from "!raw-loader!iframe-resizer/js/iframeResizer.contentWindow.min.js"; // eslint-disable-line
const SmartFrame = ({ children, ...props }) => {
const ref = React.createRef();
// Component did mount
useEffect(() => {
const path = require("path");
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
const StyleLintPlugin = require("stylelint-webpack-plugin");
const FriendlyErrorsPlugin = require("friendly-errors-webpack-plugin");
const { CleanWebpackPlugin } = require("clean-webpack-plugin");
const ImageminPlugin = require("imagemin-webpack-plugin").default;
const TerserPlugin = require("terser-webpack-plugin");
const CopyPlugin = require("copy-webpack-plugin");
const { NODE_ENV: mode = "development" } = process.env;