Skip to content

Instantly share code, notes, and snippets.

View sontl's full-sized avatar
🤩
Learning and Making Things

Son Tran Lam sontl

🤩
Learning and Making Things
View GitHub Profile
@sontl
sontl / country-detect-cf-worker.js
Created December 27, 2024 07:49
Country detection using CF Worker
addEventListener('fetch', event => {
event.respondWith(handleRequest(event.request))
})
async function handleRequest(request) {
const headers = {
'Access-Control-Allow-Origin': '*',
'Content-Type': 'application/json'
}
@sontl
sontl / MissingInteger.js
Created April 5, 2015 02:19
Codility - MissingInteger
// you can use console.log for debugging purposes, i.e.
// console.log('this is a debug message');
// you can use console.log for debugging purposes, i.e.
// console.log('this is a debug message');
function solution(A) {
// write your code in JavaScript (Node.js 0.12)
var counting = [];
for ( var i = 0; i < A.length; i++) {
if(counting[A[i]]){
@sontl
sontl / FrogRiverOne.js
Last active August 29, 2015 14:18
Codility - Counting: FrogRiverOne
function solution(X, A) {
// write your code in JavaScript (Node.js 0.12)
var count = new Array(X);
for ( var i=0; i < A.length; i++) {
var info = {
minute : i,
count : 1
};
if (!count[A[i]])
count[A[i]] = info;