Skip to content

Instantly share code, notes, and snippets.

Pasindu Perera udnisap

Block or report user

Report or block udnisap

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script>
let data = [1,10,4,5,3,5,1,4,5];
</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jasmine/3.3.0/jasmine.js"></script>
View React Redux SWAPI
a) Create a simple ReactJS front end in JS Fiddle using the Star Wars API https://swapi.co/
b) List all the films in first page
c) List all the Characters in a film when you click on a film
d) Bonus points if you use React with Redux/Flux
e) Make sure your front end is responsive
View gist:9f5b6865cb3317e5b208e36f07170512
// main function
customers = readFile('customer.dat');
prefCustomers = readFile('preffrred.dat')
orders = readFile('orders.dat')
for (order in orders){
customer = order.getCustomer();
subtotal = order.calcuateTotal();
currentAmountSpent = customer.getAmountSpent;
View gist:d82f40b3066af5e3f22a763d5ce317c8
# To Display disk mapping
lsblk
# Erase the disk with random strings
dd if=/dev/urandom of=/dev/null status=progress
View Concurrency.js
const API = 'https://jsonplaceholder.typicode.com';
// Data Fetching and Logic
const getData = (endpoint) =>
fetch(`${API}/${endpoint}`)
.then(resp => resp.json());
const findUserByUserName = (username) =>
getData(`users?username=${username}`)
@udnisap
udnisap / rate_limit.js
Last active Nov 9, 2019 — forked from epogue/rate_limit.js
This will make sure(most of the times) the concurrent invocation is handled
View rate_limit.js
/* Extend the Underscore object with the following methods */
// Rate limit ensures a function is never called more than every [rate]ms
// Unlike underscore's _.throttle function, function calls are queued so that
// requests are never lost and simply deferred until some other time
//
// Parameters
// * func - function to rate limit
// * rate - minimum time to wait between function calls
// * async - if async is true, we won't wait (rate) for the function to complete before queueing the next request
View dbDump.php
$con = mysqli_connect ( $MYSQL_HOSTNAME, $MYSQL_USERNAME, $MYSQL_PASSWORD, $MYSQL_DATABASE );
$tables = array ();
$result = mysqli_query ( $con, 'SHOW TABLES' );
while ( $row = mysqli_fetch_array ( $result ) ) {
$tables [] = $row [0];
}
// cycle through the tables
foreach ( $tables as $table ) {
View PageObject
var codeTemplate = '\
\
<ul class="people_list"> \
{{#each people}} \
<li>{{this}}</li> \
{{/each}} \
</ul> \
\
';
@udnisap
udnisap / xPathGetter
Last active Aug 29, 2015
xPathGetter
View xPathGetter
if (typeof xpathGetter === 'undefined') {
xpathGetter = function(){
var isActive = false,
mode = "XPATH";//0 - xpath, 1-css, 2-id
version = "0.1",
codeTemplate = null,
iniatilized = false;
var pub = {};
var self = {
You can’t perform that action at this time.