Skip to content

Instantly share code, notes, and snippets.

View unreadable's full-sized avatar
🕊️

unreadable

🕊️
View GitHub Profile
function Person(firstandlast) {
var full = firstandlast;
var first = firstandlast.split(' ')[0];
var last = firstandlast.split(' ')[1];
this.getFirstName = function(){return first;};
this.getLastName = function(){return last;};
this.getFullName = function(){return first + ' ' + last;};
this.setFirstName = function(newFirstName){first = newFirstName;};
function updateInventory(arr1, arr2) {
var cart = arr1.concat(arr2);
var sum = [];
var dif = [];
for (var i = 0; i < arr1.length; i++) {
for (var j = 0; j < arr2.length; j++) {
if (arr1[i][1] == arr2[j][1]) {
var arr = [ [ 'TWENTY', 20 ],
[ 'TWENTY', 20 ],
[ 'TWENTY', 20 ],
[ 'TEN', 10 ],
[ 'TEN', 10 ],
[ 'FIVE', 5 ],
[ 'FIVE', 5 ],
[ 'FIVE', 5 ],
[ 'ONE', 1 ],
[ 'QUARTER', 0.25 ],
function permAlone(str) {
var arr = str.split(''); var perm = []; var ar;
function swap(i, j) {
ar = arr[i];
arr[i] = arr[j];
arr[j] = ar;
}
function generate(e) {
//client side
var socket = io.connect('http://localhost:3000');
var room = "abc123";
socket.on('connect', function() {
$('button').click(function() {
socket.emit('room', room);
})
import React from 'react'
import io from 'socket.io-client'
const socket = io()
class App extends React.Component {
constructor() {
super();
this.state = {messages: [], value: ''}
this.handle = this.handle.bind(this)
this.submit = this.submit.bind(this)
@unreadable
unreadable / Operator.cpp
Last active March 15, 2017 12:09
Gravity c++
#include <iostream>
#include <cstring>
#define _CRT_SECURE_NO_WARNINGS
using namespace std;
class Sir
{
private:
@unreadable
unreadable / hi-lo.cpp
Created November 12, 2016 11:02
Hi-Lo Game!
#include <iostream>
#include <random>
int generator() {
using namespace std;
std::random_device rd; // obtain a random number from hardware
std::mt19937 random(rd()); // seed the generator
std::uniform_int_distribution<> range(1, 100); //
return range(random);
@unreadable
unreadable / sort.cpp
Created November 13, 2016 10:48
Sort array
#include <iostream>
void bubble(int* arr, int length) {
int c{};
for (int i = 0; i < length - 1; i++) {
if (arr[i] > arr[i+1]) {
arr[i] = arr[i]*arr[i+1];
arr[i+1] = arr[i] / arr[i+1];
arr[i]= arr[i] / arr[i+1];
c++;
@unreadable
unreadable / Recursive Binary Converter
Created November 26, 2016 16:10
Recursive Binary Converter
#include <iostream>
void printBinary(int x)
{
// Termination case
if (x <= 0)
return;
// Recurse to the next bit
printBinary(x / 2);