Skip to content

Instantly share code, notes, and snippets.

View sammccord's full-sized avatar
🤘
W̸A̵VY͡

Sam McCord sammccord

🤘
W̸A̵VY͡
View GitHub Profile
const copyToClipboard = str => {
const el = document.createElement('textarea') // Create a <textarea> element
el.value = str // Set its value to the string that you want copied
el.setAttribute('readonly', '') // Make it readonly to be tamper-proof
el.style.position = 'absolute'
el.style.left = '-9999px' // Move outside the screen to make it invisible
document.body.appendChild(el) // Append the <textarea> element to the HTML document
const selected =
document.getSelection().rangeCount > 0 // Check if there is any content selected previously
? document.getSelection().getRangeAt(0) // Store selection if found

Keybase proof

I hereby claim:

  • I am sammccord on github.
  • I am sammccord (https://keybase.io/sammccord) on keybase.
  • I have a public key ASBXB_7uJ10TFL8kbp_I1xLCdLR5XL1Wp7rzQr8EybI9nwo

To claim this, I am signing this object:

@sammccord
sammccord / cors.xml
Created December 11, 2017 21:49
cors
<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
<AllowedOrigin>*</AllowedOrigin>
<AllowedMethod>GET</AllowedMethod>
<AllowedMethod>PUT</AllowedMethod>
<AllowedMethod>POST</AllowedMethod>
<AllowedMethod>DELETE</AllowedMethod>
<ExposeHeader>ETag</ExposeHeader>
<AllowedHeader>*</AllowedHeader>
@sammccord
sammccord / thing.js
Created April 21, 2016 17:12
sadjhb
'use strict';
angular.module('georgieStClaireApp')
.config(function ($stateProvider) {
$stateProvider
.state('main', {
url: '/',
templateUrl: 'app/main/main.html',
controller: 'MainCtrl',
authenticate : true
var _rooms = {};
function Room(_id,tab_id){
var socket;
socket = io.connect('http://192.168.1.24:9000', {
query: 'page='+_id,
path: '/socket.io-client',
transports: ['websocket'],
'force new connection': true
@sammccord
sammccord / AngularAdaptations.js
Last active August 29, 2015 14:12
Node, AWS, and Angular approach for S3 uploading
//Angular doesn't like ng-change with file inputs, so use the onchange event in the tag itself
<input id="file-upload" type="file" class="form-control" onchange="angular.element(this).scope().upload()"></input>
//Run this function when the input is changed
$scope.upload = function(thing){
//Lines 7 and 8 are reliable ways to pull out the file name so it's saved in a friendly manner in the bucket.
var file_name = angular.element('#file-upload').val().split('\\');
file_name = file_name[file_name.length-1];
console.log(file_name);