Skip to content

Instantly share code, notes, and snippets.

View simsketch's full-sized avatar
💻
Coding

Elon Zito simsketch

💻
Coding
View GitHub Profile
@simsketch
simsketch / addMin.sql
Created August 6, 2014 17:55
PHPmyAdmin add administrator user in WordPress
INSERT INTO `databasename`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('4', 'demo', MD5('demo'), 'Syed Balkhi', 'test@yourdomain.com', 'http://www.wpbeginner.com/', '2011-06-07 00:00:00', '', '0', 'Syed Balkhi');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');
INSERT INTO `databasename`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_user_level', '10');
@simsketch
simsketch / removeSound
Created August 14, 2014 19:39
remove sound
<script type="text/javascript">
jQuery( document ).ready(function( $ ) {
$('.container').find('audio, video').each(function(){
this.volume = 0;
});
});
</script>
@simsketch
simsketch / trianglifyInit.html
Created September 20, 2014 22:37
trianglifyInit
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="assets/js/trianglify.js"></script>
<script type="text/javascript">
var t = new Trianglify({cellsize:520,noiseIntensity:0,x_gradient:["#800026","#bd0026","#e31a1c","#fc4e2a","#fd8d3c","#feb24c","#fed976"] });
var d = document.getElementById("hero");
var pattern = t.generate(document.body.clientWidth, document.body.clientHeight);
d.setAttribute('style', 'background-image: '+pattern.dataUrl);
</script>

Twitter autoresponder bot

By Daniel15 (dan.cx) This is a very simple Twitter autoresponder bot. It requires PECL OAuth extension to be installed (run "pecl install oauth", or if on Windows, grab php-oauth.dll. If using cPanel you can install it via WHM). The authentication is designed for command-line usage, it won't work too well via a web browser. You'll have to sign up for an application on Twitter's site to get the consumer key and secret.

Could be modified to be more advanced (match regular expressions to answer questions, etc.)

Questions? See my blog post - http://dan.cx/blog/2011/06/twitter-autoreply-bot-dbznappa

Modified 2013-06-13 - Twitter API 1.0 discontinued, modified to use Twitter API 1.1

@simsketch
simsketch / videoPlayOnHover
Created February 7, 2015 02:19
Have a video play on hover
// something along that
var vid = document.getElementsByTagName("video");
[].forEach.call(vid, function (item) {
item.addEventListener('mouseover', hoverVideo, false);
item.addEventListener('mouseout', hideVideo, false);
});
function hoverVideo(e)
{
this.play();
@simsketch
simsketch / rssAjax.html
Created February 27, 2015 14:55
RSS feed non-secure made secure
<div id="rssdata">
<ul class="rss-items"></ul>
<div class="loading">Loading RSS items...</div>
</div>
<script type="text/javascript">
$('#rssdata').ready(function () {
var url = 'http://www.someRSSfeed.com';
$.ajax({
List the processes running on ports
netstat -a -o -n
Find the one you need. I search for 0.0.0.0:8080 and get the PID.
taskkill /F /PID <pid>
@simsketch
simsketch / pingURLwithDetails.md
Last active January 6, 2017 20:37
URL ping alias for bash

alias reqtime="curl -w '\n[HTTP %{http_version}/%{http_code}] %{content_type}\nDownloaded %{size_download}B at %{speed_download} bps (headers: %{size_header}B, request: %{size_request}B)\nUploaded %{size_upload}B at %{speed_upload} bps\n\n time_namelookup: %{time_namelookup}s\n time_connect: %{time_connect}s\n time_appconnect: %{time_appconnect}s\n time_pretransfer: %{time_pretransfer}s\n time_redirect: %{time_redirect}s\ntime_starttransfer: %{time_starttransfer}s\n ---------------------\n time_total: %{time_total}s\n\n' -o /dev/null -s"

//just put that in your bash/zsh/whatevershell profile //and then do reqtime 'url goes here' to debug the various times a bit

@simsketch
simsketch / flattenArray.js
Created February 1, 2017 16:01
Write some code, that will flatten an array of arbitrarily nested arrays of integers into a flat array of integers. e.g. [[1,2,[3]],4] -> [1,2,3,4].
function flatten(array) {
var idx,
temp = [array],
lastIdx = [-1],
result = [];
while(temp.length) {
array = temp.pop();
idx = lastIdx.pop() + 1;
@simsketch
simsketch / add_admin_user_via_ftp.php
Last active April 13, 2017 16:37
Add admin user to WordPress site via FTP
// Add this to the the functions.php inside your active theme's directory ie: wp-content/themes/twentyseventeen/functions.php
// Not sure what your active theme is? You should be able to figure that out by viewing the source, and looking at the stylesheet.
function wpb_admin_account(){
$user = 'username';
$pass = 'password';
$email = 'email@domain.com';
if ( !username_exists( $user ) && !email_exists( $email ) ) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );