Skip to main content

Posts

Showing posts with the label client side

How to convert JavaScript Date without time stamp

 At some point when setting pika date min date I had to use JavaScript date variable without time stamp. When you try JavaScript new Date() in browser console, you can see date with time stamp. To remove time stamp what I did was use new Date with year , month and day parameters. new Date(new Date().getFullYear(),new Date().getMonth() , new Date().getDate())

Typescript - Self-Executing Anonymous Functions

/** * Self executing anonymous function using TS. */ (()=> { // Whatever is here will be executed as soon as the script is loaded. console . log ( 'executed' ) })(); I want a built a plugin that may work for Node.js, also for fron-tend as well. In that case you should compile your TypeScript in AMD and use an AMD loader on the frontend, like  http://requirejs.org/docs/start.html On the server side, you would need to use  requirejs  node package as well to load the file. Take a look at this:  http://requirejs.org/docs/node.html Basically there are two ways to compile TS to JS, using AMD, which is browser compliant, or using CommonJS, which is node.js compliant. Loading an AMD script in the browser or in the server needs to use an AMD compliant loader, and *requirejs** is one of them. (the most famous/used I'd say) Ref :  https://stackoverflow.com/questions/30274464/typescript-self-executing-anonymous-functions

Zipping up files from a MemoryStream

Recently I needed to write some .NET code that zipped up some files and downloaded the zip without touching the file system. I struggled to find a good example, so I thought I’d post the code here … Assuming that we’ve got the source files in memory in the following structure: 1 2 3 4 5 6 public class SourceFile {      public string Name { get ; set ; }      public string Extension { get ; set ; }      public Byte [ ] FileBytes { get ; set ; } } We can use the following code to zip these files up and send the zip in the response: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 public ActionResult Index ( ) {      // get the source files      List < SourceFile > sourceFiles ...