Skip to content

Instantly share code, notes, and snippets.

View gnncl's full-sized avatar
🏠
Working from home

Ali Gunenc gnncl

🏠
Working from home
View GitHub Profile
@DavidWells
DavidWells / cron-utils.js
Last active June 7, 2022 11:09
Cron utilities
const cronstrue = require('cronstrue')
// https://github.com/harrisiirak/cron-parser
const MONTHS = [null, 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']
const DAYS = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']
const dayNum = {
sun: '0',
mon: '1',
tue: '2',
wed: '3',
import { ref } from 'vue'
const useCronDecoder = () => {
const decodeMinutes = (stringDate, time) => {
let date = new Date(`${stringDate} ${time}`)
let minutes = date.getMinutes();
console.log('minutes: ', minutes)
return minutes
}
import NodeCache from 'node-cache'; // or 'redis'
class CacheService {
constructor(ttlSeconds) {
// this could also be redis
this.cache = new NodeCache({ stdTTL: ttlSeconds, checkperiod: ttlSeconds * 0.2, useClones: false });
}
get(key, storeFunction) {
@teleginski
teleginski / ExpressionBuilder.cs
Last active April 29, 2021 17:08
C# .NET - Expression Builder - Dynamic Filter - Dynamic Where
public static class ExpressionBuilder
{
private static readonly MethodInfo containsMethod = typeof(string).GetMethod("Contains");
private static readonly MethodInfo toLowerMethod = typeof(string).GetMethod("ToLower", new Type[0] { });
public static Func<T, bool> GetExpression<T>(IList<Filter> filters)
{
ParameterExpression parameter = Expression.Parameter(typeof(T), "t");
Expression expression = null;
@LeighCiechanowski
LeighCiechanowski / mongoClient.js
Created March 23, 2018 14:23
Singleton MongoDB Client
import { MongoClient } from 'mongodb';
const DbConnection = function () {
var db = null;
var instance = 0;
async function DbConnect() {
try {
let url = 'mongodb://localhost:27017/articles';
/*
* Convert A String to Base64 String or Vice-Versa
*/
declare const android: any;
declare const java: any;
declare const NSData: any;
declare const NSUTF8StringEncoding: any;
declare const NSString: any;
@dlucidone
dlucidone / Nativescript String to Base64 String and Vice-Versa.ts
Last active January 31, 2021 00:53
Nativescript Base64 Manipulation Methods
/*
* Convert A String to Base64 String or Vice-Versa
*/
declare const android: any;
declare const java: any;
declare const NSData: any;
declare const NSUTF8StringEncoding: any;
declare const NSString: any;