This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function parseFile() { | |
var fileInput = document.createElement('input'); | |
fileInput.setAttribute('type', 'file'); | |
fileInput.onchange = function () { | |
var file = fileInput.files[0]; | |
var reader = new FileReader(); | |
reader.onload = function () { | |
console.log(JSON.parse(reader.result)) | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function ability() { | |
let ability = []; | |
let lowestIndex = 0; | |
let lowestScore = 6; | |
for (let i = 0; i < 4; i++) { | |
let score = (Math.floor((Math.random() * 6) + 1)); | |
ability.push(score); | |
if(score < lowestScore) { | |
lowestScore = score; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function saveFileAsZip(string filePath) { | |
using (ZipFile zip = new ZipFile()) | |
{ | |
//Add string | |
zip.AddEntry("dataset.json", "{ foo: 'bar' }"); | |
//Add file as byte array | |
zip.AddEntry("customName.json", System.IO.File.ReadAllBytes(filePath)); | |
//Add file, preserving path | |
zip.AddFile(filePath); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('uploadFile', []).service('uploadService', ['$http', function ($http) { | |
this.uploadFile = function () { | |
var field = document.createElement('input') | |
field.setAttribute('type', 'file') | |
field.setAttribute('accept', '.json, application/json') | |
field.onchange = function () { | |
var data = new FormData() | |
data.append('connectionId', 'banana') | |
data.append('fileToImport', field.files[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(fileToImport.ContentLength > 5 * 1024 * 1024) | |
{ | |
Response.StatusCode = 500; | |
Response.Write("File is too large to import! The max file size is 5MB."); | |
Response.StatusDescription = "Internal server error"; | |
return; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void Compress(FileInfo fileToCompress) | |
{ | |
var bytes = File.ReadAllBytes(fileToCompress.FullName); | |
using (FileStream fs = new FileStream(fileToCompress.FullName + ".gzip", FileMode.CreateNew)) | |
using (GZipStream zipStream = new GZipStream(fs, CompressionMode.Compress, false)) | |
{ | |
zipStream.Write(bytes, 0, bytes.Length); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function arrayCopy(to, from) { | |
Array.prototype.push.apply(to, from); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="https://code.jquery.com/jquery-1.11.3.js"></script> | |
<link rel="stylesheet" href="style.css" /> | |
</head> | |
<body> | |
<iframe></iframe> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
angular.module('testApp', []) | |
.component('parent', { | |
template: '<h2>{{$ctrl.title}}</h2><div ng-transclude></div>', | |
transclude: true, | |
controller: function() { | |
this.title = 'Foobar' | |
} | |
}) | |
.component('child', { | |
require: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class User | |
{ | |
public function save() | |
{ | |
$username = $this->input->post('name'); | |
$userData = json_decode($this->input->post('data')); | |
$doStuff($username, $userData); | |
} |
OlderNewer