Skip to content

Instantly share code, notes, and snippets.

@jayjayswal
jayjayswal / javascript_resources.md
Created June 22, 2014 18:20 — forked from jookyboi/javascript_resources.md
Here are a set of libraries, plugins and guides which may be useful to your Javascript coding.

Libraries

  • jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
  • Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
  • AngularJS - Conventions based MVC framework for HTML5 apps.
  • Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
  • lawnchair - Key/value store adapter for indexdb, localStorage
@jayjayswal
jayjayswal / get Height of Document any Browser
Last active August 29, 2015 14:12
Get Height of document in any browser
function getDocHeight() {
var D = document;
return Math.max(
D.body.scrollHeight, D.documentElement.scrollHeight,
D.body.offsetHeight, D.documentElement.offsetHeight,
D.body.clientHeight, D.documentElement.clientHeight
);
}
@jayjayswal
jayjayswal / php mysql utc to local timestamp
Last active August 29, 2015 14:12
Convert mysql UTC timestamp to Local timestamp PHP
function convert_time($timestamp,$timezone)
{
date_default_timezone_set("UTC");
$time_object = new DateTime($timestamp, new DateTimeZone('UTC'));
$time_object->setTimezone(new DateTimeZone($timezone));
return $time_object->format('Y-m-d g:i A');
}
@jayjayswal
jayjayswal / stohi.c
Created February 21, 2015 18:35
Convert IP address to integer and convert it back in c
#include <stdio.h>
#include <stdlib.h>
union
{
unsigned int integer;
unsigned char byte[4];
} itoch;
main(){
printf("Converting IP: 32.0.45.54\n");
@jayjayswal
jayjayswal / Synchronization.md
Last active August 29, 2015 14:15
Version Control System and Synchronization System between Desktop and Web applications

Version Control System and Synchronization System between Desktop and Web applications

Activity log created at local desktop database

Steps:

  1. When internet connected, first update all activity log from local database to server.
  2. Download snippet info(xml) from database
  3. Compare it with local database (update newly created snippet from server to DA and delete snippet if it’s exist on DA but not at server.
@jayjayswal
jayjayswal / lambdaAMIBackups.py
Created August 19, 2018 07:10 — forked from bkozora/lambdaAMIBackups.py
AWS Lambda AMI Backups
# Automated AMI Backups
#
# @author Robert Kozora <[email protected]>
#
# This script will search for all instances having a tag with "Backup" or "backup"
# on it. As soon as we have the instances list, we loop through each instance
# and create an AMI of it. Also, it will look for a "Retention" tag key which
# will be used as a retention policy number in days. If there is no tag with
# that name, it will use a 7 days default value for each AMI.
#
@jayjayswal
jayjayswal / lambdaAMICleanup.py
Created August 19, 2018 07:14 — forked from bkozora/lambdaAMICleanup.py
AWS Lambda Function to Delete AMIs and Snapshots
# Automated AMI and Snapshot Deletion
#
# @author Robert Kozora <[email protected]>
#
# This script will search for all instances having a tag with "Backup" or "backup"
# on it. As soon as we have the instances list, we loop through each instance
# and reference the AMIs of that instance. We check that the latest daily backup
# succeeded then we store every image that's reached its DeleteOn tag's date for
# deletion. We then loop through the AMIs, deregister them and remove all the
# snapshots associated with that AMI.
@jayjayswal
jayjayswal / teserflow_gpu_test.py
Last active December 29, 2018 11:18
teserflow gpu test
import tensorflow as tf
with tf.device('/gpu:0'):
a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
c = tf.matmul(a, b)
with tf.Session() as sess:
print (sess.run(c))
# https://medium.com/@omar.merghany95/how-to-install-tensorflow-gpu-with-cuda-toolkit-9-0-and-cudnn-7-2-1-on-aws-ec2-ubuntu-16-04-c46b469a7358
package main
import (
"errors"
"fmt"
"reflect"
)
//func foo() (arr string) {
// arr="foo called"
package main
import (
"errors"
"sync"
)
func test(i int) (int, error) {
if i > 2 {
return 0, errors.New("test error")