Skip to content

Instantly share code, notes, and snippets.

View asaladino's full-sized avatar

Adam Saladino asaladino

View GitHub Profile
@asaladino
asaladino / Code.js
Created July 11, 2019 15:18
Simple React Code Component
// noinspection ES6CheckImport
import PropTypes from 'prop-types';
import React, {useState} from 'react';
import {CopyToClipboard} from 'react-copy-to-clipboard';
import IconButton from '@material-ui/core/IconButton';
import CopyIcon from '@material-ui/icons/FileCopy';
import Snackbar from '@material-ui/core/Snackbar';
import makeStyles from '@material-ui/core/styles/makeStyles';
const useStyles = makeStyles(theme => ({
@asaladino
asaladino / MyTest.cs
Last active February 21, 2019 16:37
UserManager in my unit tests.
using System.Web;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin;
using System.Net.Http;
using Microsoft.Owin;
using Microsoft.AspNet.Identity.EntityFramework;
using System.Data.Entity.Migrations;
namespace MyWebsite.Repositories.Tests
{
@asaladino
asaladino / functions.php
Last active February 21, 2019 16:08
Wordpress REST Api with CPTUI and ACF
<?php
add_action('rest_api_init', function() {
// Create url /wp-json/cs/v1/projects
register_rest_route('cs/v1', '/projects', [[
'methods' => \WP_REST_Server::READABLE,
'callback' => function($request) {
// Get all the posts for your CPTUI post type
$posts = get_posts(['posts_per_page' => -1, 'post_type' => 'projects']);
// Add all the fields from ACP to the meta field.
foreach($posts as &$post) {
@asaladino
asaladino / AndroidManifest.xml
Created February 13, 2019 21:02
Android WebView File Upload
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.codingsimply.project">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
</manifest>
@asaladino
asaladino / .my.cnf
Created February 5, 2019 21:35
Sample my.cnf
[mysqldump]
user=database_username
password=database_password
@asaladino
asaladino / sync-uploads-from-prod.ps1
Created February 3, 2019 13:27
Retrieve a remote folder locally.
## This will work on windows/powershell and linux/bash
scp -r user@server.com:/remote/folder/location/to/get/ .\local\parent\directory
## The folder get will be created in .\local\parent\directory so you will see
## .\local\parent\directory\get\
# Most of this script will work on bash/linux and powershell/windows.
## Dump SQL to remote location.
ssh user@server.com "mysqldump -P3306 -hmysql.server.com -u dbuser database > contents.sql"
## Get remote SQL dump file and transfer it locally.
scp -rp user@server.com:/remote/sql/dump/location/contents.sql C:\Temp\
## Remove the remote SQL Dump.
ssh user@server.com "rm contents.sql"
## Powershell only.
## Replace any strings in the sql dump.
@asaladino
asaladino / faculty-staff-extron-extract.js
Created February 20, 2017 19:01
Extract all the faculty staff entries from the faculty staff widget.
// I modified the widget so each entry will have a data-id attribute with the url for the detail view.
var html = '<table>';
$('table.archive-list tr').each(function() {
var url = $(this).find('span:first').attr('data-id');
var name = $(this).find('td a').text();
html += '<tr><td>' + name + '</td><td>' + url + '</td></tr>';
});
$('body').html(html + '</table>');