Skip to content

Instantly share code, notes, and snippets.

View Ksengine's full-sized avatar
:octocat:
coding is fun!!!

Kavindu Santhusa Ksengine

:octocat:
coding is fun!!!
View GitHub Profile
@Ksengine
Ksengine / case.py
Last active December 2, 2020 16:38
String cases algorithms for python
def camel_to_snake(str):
"""
camelCase to snake_case
'camelCase' -> 'camel_case'
"""
return ''.join(map(lambda char:char if char.islower() else "_"+char.lower(), str))
def snake_to_camel(str):
"""
@aleclarson
aleclarson / rollup-typescript.md
Last active June 21, 2024 03:25
The best Rollup config for TypeScript libraries

Features

🔥 Blazing fast builds
😇 CommonJS bundle
🌲 .mjs bundle
.d.ts bundle + type-checking
🧐 Source maps

Install

@Ksengine
Ksengine / PSON.py
Last active December 19, 2020 13:58
""" Python Script Object Notation (PSON) """
# JSON alternative for Python.
def stringify(obj):
return str(obj)
def parse(string):
if string[0] == ' ':
@Ksengine
Ksengine / kalculator.py
Last active December 5, 2020 10:23
# Kalculator
#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import print_function
import readline # for better console text edit experience
def isnumeric(number):
for num in range(10):
if str(number[-1])==str(num):
return True
var inputs = document.querySelectorAll("input.js-toggler-target[value='Follow']");
for(var i=0; i<inputs.length;i++) {inputs[i].click();}
@Danilovonline
Danilovonline / cross_browser_ajax.js
Last active December 1, 2020 14:04
Cross-browser AJAX(pure JS)
function httpRequest(url, method, data, success_callback, failure_callback) {
var xhr;
var data2 = [];
if (typeof data == 'object') {
for(var index in data) {
if (data.hasOwnProperty(index)) {
data2[data2.length] =index+'='+data[index];
}
}
@WebReflection
WebReflection / WeakMap.js
Last active December 30, 2022 13:52
An alternative, less memory greedy, more robust WeakMap polyfill.
var WeakMap = WeakMap || (function (Object) {
/*! (C) Andrea Giammarchi - Mit Style License */
var
dP = Object.defineProperty,
hOP = Object.hasOwnProperty,
WeakMapPrototype = WeakMap.prototype,
i = 0
;