Skip to content

Instantly share code, notes, and snippets.

View nhobi's full-sized avatar
🌼

Nate nhobi

🌼
View GitHub Profile
@nhobi
nhobi / functions.php
Last active April 8, 2016 17:43
Responsive WordPress oEmbeds
<?php
function responsive_oembed_filter($markup, $url, $attr, $post_ID) {
return '<div class="video-container">' . $markup . '</div>';
}
add_filter( 'embed_oembed_html', 'responsive_oembed_filter');
@nhobi
nhobi / Logger.cs
Last active April 13, 2016 15:16
Dead simple C# logging without config file dependency.
using System;
using System.IO;
public class Logger
{
private string LogFilePath { get; set; }
private string FileExtension { get; set; }
private string FilePrefix { get; set; }
public Logger(string path, string filePrefix = "Log", string fileExtension = ".txt")
@nhobi
nhobi / dd.sublime-snippet
Last active October 4, 2017 17:46
A quick, one-line PHP debugging snippet for Sublime Text. Think Laravel's dd() helper function for non-Laravel things.
<snippet>
<content><![CDATA[
echo '<pre>'; var_dump(\$${1:variable_name_here}); echo '</pre>'; exit();
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>dd</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>source.php</scope>
</snippet>
@nhobi
nhobi / find_base64_eval.php
Created December 1, 2016 18:18
Use this script (that I didn't write) to look for malicious code on your server.
<html><head><title>Find String</title></head><body>
<?php
// ini_set('max_execution_time', '0');
// ini_set('set_time_limit', '0');
find_files('.');
function find_files($seed) {
if(! is_dir($seed)) return false;
$files = array();
$dirs = array($seed);
while(NULL !== ($dir = array_pop($dirs)))
@nhobi
nhobi / rncom.sublime-snippet
Created April 17, 2017 14:40
New React Native Component
<snippet>
<content><![CDATA[
import React, { Component } from "react";
import {
View,
Text,
TouchableWithoutFeedback,
Image,
Animated
} from "react-native";
<snippet>
<content><![CDATA[
this.${1:func} = this.${1:func}.bind(this);
]]></content>
<description>Bind class methods in constructor for React components.</description>
<tabTrigger>bind</tabTrigger>
<scope>source.js</scope>
</snippet>
@nhobi
nhobi / keyByRecursive.php
Last active June 15, 2023 23:43
Collection keyByRecursive macro
<?php
Illuminate\Support\Collection::macro('keyByRecursive', function ($func) {
return $this->keyBy(function ($value, $key) use ($func) {
return $func($value, $key);
})->map(function ($item) use ($func) {
@nhobi
nhobi / cloudinary.sh
Last active May 20, 2019 16:14
Network Request
# Note: Both these requests are being fired by the cloudinary medialibrary js code, not my code.
# Works! This is 'copy as curl' from Chrome, where I don't get the 401 error.
curl 'https://cloudinary.com/console/api/v1/auth/login_from_session' \
-H 'pragma: no-cache'
-H 'cookie: _ga=GA1.2.813819547.1538000561; __utma=136482402.813819547.1538000561.1557868798.1557868798.1; __utmz=136482402.1557868798.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); _mkto_trk=id:396-LRB-524&token:_mch-cloudinary.com-1557868798202-41547; intercom-session-f8c4avgs=eU9ZUWlHa3M4SGRKdmMrTjZKU2cvM2FwNkc2blRiaFVoNnFqOHp6OGxVWFBtREo3cFZxOWdCNnNQVnM3cjR2Ry0td2FtY083YVlQY1F1dXQvNXAzRERNQT09--23ea95a8522a7e2e61e0f2a9d427399076fffd0b; new_ml_enabled=yes; _cld_session_key=9a4aad31e7fdfb49e8c2d84aa0058260; _gid=GA1.2.1358471984.1558366586; _gat_UA-25966579-7=1; AWSALB=KOnDJDzN5FvI0QMXbBowU1lYTxi1xdSr8cQEJIDYz2uVPho7FamV++d8iSWr6moSaze+QFXg9Q3s+zK6VB+gL7CIXsU9TGaPImTHfZh9NWD06pHOG4dWJX9hhTl4'
-H 'accept-encoding: gzip, deflate, br' \
// Fonts
@import url("https://fonts.googleapis.com/css?family=Nunito");
// Variables
@import "variables";
@import "keyframes";
@import "animations";
// Bootstrap
@import "~bootstrap/scss/bootstrap";
@nhobi
nhobi / listeningWallBuilderStore.js
Created May 3, 2021 05:44
An example VueX store from Listening Wall.
import { createNamespacedHelpers } from "vuex";
import Axios from "axios";
import { getHelperWords, getWordObj } from "../functions/helperWords";
import builderUtils from "../functions/builderUtils";
import randomString from "../functions/randomString";
export default {
...createNamespacedHelpers("builder"),
namespaced: true,