Skip to content

Instantly share code, notes, and snippets.

@nedimcanulusoy
nedimcanulusoy / ts_4_py_cheatsheet.md
Last active November 29, 2025 14:29
Python to TypeScript Cheatsheet

Python to TypeScript Cheatsheet

Basic Concepts

  • Variables & Types

    • Python: Dynamically typed. x = 5
    • TypeScript: Statically typed. let x: number = 5;
  • Strings

  • Python: x = "Hello"

@kentbrew
kentbrew / favicon-interceptor.js
Created January 3, 2011 19:32
How to short-circuit those annoying favicon requests in node.js
// early experiments with node had mysterious double requests
// turned out these were for the stoopid favicon
// here's how to short-circuit those requests
// and stop seeing 404 errors in your client console
var http = require('http');
http.createServer(function (q, r) {
// control for favicon
@jameshartig
jameshartig / gist:762874
Created January 2, 2011 22:20
Get IP of user in node.js and CloudFlare-compatible
function getIP(req) {
var ip_address = (req.connection.remoteAddress ? req.connection.remoteAddress : req.remoteAddress);
//check for cloudflare
try {
if (req.headers['cf-connecting-ip']) {
var ipParts = ip_address.split(".");
var cloudFlare = false;
switch (parseInt(ipParts[0])) {
case 204:
//(204.93.177.0 - 204.93.177.255)