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 | |
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1800)) { | |
// last request was more than 30 minutes ago | |
session_unset(); // unset $_SESSION variable for the run-time | |
session_destroy(); // destroy session data in storage | |
} | |
$_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp |
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
const numberToWords = function(num) { | |
let result = toHundreds(num % 1000); | |
const bigNumbers = ["Thousand", "Million", "Billion"]; | |
for (let i = 0; i < 3; ++i) { | |
num = Math.trunc(num / 1000); | |
result = num % 1000 !== 0 ? [toHundreds(num % 1000), bigNumbers[i], result].filter(Boolean).join(" ") : result; | |
} | |
return result.length === 0 ? "Zero" : result; | |
} | |
function toHundreds(num) { |
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
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
"""This module's docstring summary line. | |
This is a multi-line docstring. Paragraphs are separated with blank lines. | |
Lines conform to 79-column limit. | |
Module and packages names should be short, lower_case_with_underscores. | |
Notice that this in not PEP8-cheatsheet.py |
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
using System; | |
using System.Net.Http; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Moq; | |
using Moq.Protected; | |
namespace Tests | |
{ | |
public class MockHttpClient |
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
/** | |
* How to check if a date is valid with vanilla JavaScript | |
* @link https://gomakethings.com/how-to-check-if-a-date-is-valid-with-vanilla-javascript/ | |
*/ | |
/** | |
* Get the number of days in any particular month | |
* @link https://stackoverflow.com/a/1433119/1293256 | |
* @param {integer} m The month (valid: 0-11) | |
* @param {integer} y The year |
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
/// <summary> | |
/// Observer class | |
/// </summary> | |
abstract class Observer | |
{ | |
public abstract void notify(string eventName, object eventValue); | |
} | |
/// <summary> | |
/// Observable class |
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
pragma solidity ^0.4.0; | |
contract Ballot { | |
struct Voter { | |
uint weight; | |
bool voted; | |
uint8 vote; | |
address delegate; | |
} | |
struct Proposal { |
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
const maxAge = 30; // maximum cache age (min) | |
/** | |
* Gets the cached data for the specified request. | |
* @param url The request URL. | |
* @return The cached data or null if no cached data exists for this request. | |
*/ | |
getCacheData(url: string): HttpResponse<any> | null { | |
const cacheEntry = this.cachedData[url]; |
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
pragma solidity ^0.4.0; | |
contract Ballot { | |
struct Voter { | |
uint weight; | |
bool voted; | |
uint8 vote; | |
address delegate; | |
} | |
struct Proposal { |