Skip to content

Instantly share code, notes, and snippets.

@chrisdel101
chrisdel101 / lines.py
Created May 31, 2018 03:15
Lines from similarites
def lines(file1, file2):
result = set()
def getLinesList(file):
# storage array
fileList = []
# temp storage array
tempList = []
# if all lines have \n at the end
@chrisdel101
chrisdel101 / fake_ajax.js
Last active July 30, 2018 16:51
Test ajax errors
//BASIC FUNCTION
function fetchJSON (src) {
let promise = $.ajax({
dataType: 'json',
url: src,
error: function (jqXHR, response) {
console.log('inside')
console.log(jqXHR)
var msg = ''
@chrisdel101
chrisdel101 / express.js
Last active September 6, 2018 03:41
Data passing
// controller.js
module.exports = {
extractDims: (inputUrl) => {
//this gets the nums form the URL
return stuff
},
resize: (path, format, width, height) => {
//this does some image processing
Warning: the running version of Bundler is older than the version that created the lockfile. We suggest you upgrade to the latest version of Bundler by running `gem install bundler`.
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Using rake 10.4.2
Using backports 3.6.8
Using daemons 1.2.4
Installing eventmachine 1.2.0.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
// get array of ids
function getTopIDs(url) {
return fetch(url).then(blob => blob.json()).then(json => json)
}
// returns a promise resolves to an object
function getStory(id) {
let url = `https://hacker-news.firebaseio.com/v0/item/${id}.json?print=pretty`
return fetch(url).then(blob => blob.json()).then(json => json)
}
@chrisdel101
chrisdel101 / .js
Last active January 22, 2019 21:07
.includes with class
if(this.props.indexes){
//so props does exist
if(i === 100){
console.log(this.props.indexes.includes(i))
//this is true
}
return(
//yet this still does not add the class on 100
<div className={`box ${(this.props.indexes.includes(i) ? 'backgroundColor' : '')}`}>
</div>
@chrisdel101
chrisdel101 / deleteOccurences.c
Created May 12, 2019 20:41
deleteOccurences
#include <stddef.h>
int delete_nth(size_t szin, int order[szin], int max_e, size_t *szout);
int main(void) {
// 12311223345
int order[] = {1,2,3,1,1,2,1,2,3,3,2,4,5,3,1};
int res = delete_nth(14, order, 3, NULL);
printf("RES:%i\n",res );
@chrisdel101
chrisdel101 / test.js
Created June 5, 2019 18:57
Example of using computed
// When input it blank, this returns the error
// INPUT
<fg-input
v-model="editCustomer.firstName"
placeholder="First Name"
label="First Name"
name="firstName"
:error="handleErrors"
></fg-input>
// inside computed
formErrors() {
return {
firstNameError: () => {
if(!this.editCustomer.firstName){
return this.errorMessages.blankError
}
},
lastNameError: () => {
if(!this.editCustomer.lastName){
@chrisdel101
chrisdel101 / input.c
Created June 10, 2019 22:44
Entering inputs
int main(void){
//enter number of times input with propmpt for string
int count;
puts("Enter count: ");
scanf("%i", &count);
// hack so it does not shallow fget
getchar();
// 1000 is arbitraty
char arr[count][1000];
for (size_t i = 0; i < count; i++)