Skip to content

Instantly share code, notes, and snippets.

View gs-ysingh's full-sized avatar

Yogesh Singh gs-ysingh

View GitHub Profile
<script src = "scripts/form.js"></script>
<div class="container" ng-app="formApp" ng-controller="formController">
<div class="col-md-6 col-md-offset-3">
<!-- PAGE TITLE -->
<div class="page-header">
<h1><span class="glyphicon glyphicon-tower" style="font-size:20px"></span><span style="font-size:20px; margin-left:10px;">Send a direct e-mail to us</span></h1>
</div>
<!-- SHOW ERROR/SUCCESS MESSAGES -->
<div id="messages" class="well" ng-show="message"></div>
<!-- FORM -->
// define angular module/app
var formApp = angular.module('formApp', []);
// create angular controller and pass in $scope and $http
function formController($scope, $http) {
// create a blank object to hold our form information
// $scope will allow this to pass between controller and view
$scope.formData = {};
<?php
require_once('class.phpmailer.php');
$errors = array(); // array to hold validation errors
$data = array(); // array to pass back data
// validate the variables ======================================================
if (empty($_POST['name']))
$errors['name'] = 'Name is required.';
module.exports = function (info) {
//private variable
var values = {};
for(var prop in info) {
if(values[prop] !== 'undefined') {
values[prop] = info[prop];
}
}
//return public function
return {
//index.js
var Project = function() {
this.info = {};
this.setValues = function(info) {
for(var prop in info) {
if(this.info[prop] !== 'undefined') {
this.info[prop] = info[prop];
}
//index.js
var Project = function() {
this.info = {};
this.setValues = function(info) {
for(var prop in info) {
if(this.info[prop] !== 'undefined') {
this.info[prop] = info[prop];
}
}
};
@gs-ysingh
gs-ysingh / interview.js
Last active February 17, 2022 06:13
JS Interview
1. Write poly-fill of Object.create and explain why it worked:
if(typeof Object.create != "function") {
Object.create = function(param) {
var Fun = function(){};
Fun.prototype = param;
return new Fun();
}
}
@gs-ysingh
gs-ysingh / plan.js
Last active July 23, 2020 16:37
Must do for frontend
1. https://www.geeksforgeeks.org/top-10-algorithms-in-interview-questions/
2. Dynamic Programming for Coding Interviews: A Bottom-Up Approach to Problem Solving
3. Narasimha karumanchi - Algorithms
4. https://www.hiredintech.com/system-design/
5. Design from https://github.com/jwasham/coding-interview-university
<input id="inputText" type="text" />
function DataBind(domElement, object) {
this.element = domElement.element;
this.attribute = domElement.attribute;
this.event = domElement.event;
this.value = this.element[this.attribute];
var self = this;
function Cache(maxSize) {
this.data = [];
this.maxSize = maxSize;
this.size = 0;
this.put = function(key, value, ttl) {
if(value.length > this.maxSize) {
throw new Error('string is too large');
}