This file contains hidden or 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 isNullOrUndefined(variable) { | |
| // We use '==' instead of '===', because it will automatically cast the varaible to null | |
| // if it is undefined. There are no other side-effects, so this is one of the few cases | |
| // where the use of '==' is justified. | |
| return variable == null; | |
| } |
This file contains hidden or 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('demo', []) | |
| .component('inputDemo', { | |
| require: { | |
| parent: '^ngModel' | |
| }, | |
| template: '<input ng-model="$ctrl.text" /><button ng-click="$ctrl.update()">change</button>', | |
| controller: function($timeout) { | |
| var $ctrl = this; | |
| $ctrl.text; |
This file contains hidden or 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); | |
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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); |