Skip to content

Instantly share code, notes, and snippets.

#Newbie programmer
def factorial(x):
if x == 0:
return 1
else:
return x * factorial(x - 1)
print factorial(6)
#First year programmer, studied Pascal
#!/usr/bin/env python
import os
import datetime
import time
import urllib2
def getcsv(se):
response = urllib2.urlopen('http://dsecse.latest.nsmgr8.appspot.com/'+se)
fname = response.headers['content-disposition']

README

LaTeX Preamble

Created by Mark Eli Kalderon on 2008-07-30

Introduction

LaTeX preamble and associated files. Meant to be used as a submodule of a Git repository. The file, preamble.tex, needs to be included in the LaTeX document under version control. See the provided template. For more information about keeping your LaTeX preamble in a Git submodule see this blog post.

#!/usr/bin/env python
from itertools import islice, count
def eratosthenes_improved(n):
''' Slightly improved version of Eratosthenes Sieve algorithm.
This algorithm do not store an array of numbers to rule out composites.
Instead it uses a dictionary of special composite numbers only, hence saving
memory. It also rules out even numbers in the loop, making less iteration. '''
@nsmgr8
nsmgr8 / sinx.c
Created June 1, 2011 08:07
sine taylor series for projanmo forum query
#include <stdio.h>
#include <math.h>
long fact(long p) {
long i, mult = 1;
for(i=1; i<=p; i++)
mult *= i;
return mult;
@nsmgr8
nsmgr8 / prime.cpp
Created June 16, 2011 19:16
projanmo forum find primes
#include <iostream>
#include <map>
#include <vector>
#include <cstdlib>
using namespace std;
void all_primes(int n, vector<int> &primes) {
if(n < 2)
return;
@nsmgr8
nsmgr8 / djhello.py
Last active April 12, 2020 16:53
The minimal django hello world! However, never, ever, NEVER write such code. Always modularise your code and follow the popular/de-facto/standard convention.
from django.conf.urls import url
from django.http import HttpResponse
DEBUG, ROOT_URLCONF, SECRET_KEY = True, __name__, '.'
urlpatterns = url('', lambda _: HttpResponse('Hello world')),

Keybase proof

I hereby claim:

  • I am nsmgr8 on github.
  • I am nasim (https://keybase.io/nasim) on keybase.
  • I have a public key ASCELb0nkgYHDixCTz36D6HEFeA2z7j42DARx0cPUGpTrgo

To claim this, I am signing this object:

process.env.ts
@nsmgr8
nsmgr8 / fb_quiz_unlock_digits.py
Last active April 14, 2020 08:51
Quiz from facebook python BD group
from typing import NamedTuple, Callable
class KeyCombination(NamedTuple):
first: int
second: int
third: int
def __str__(self):
return f'{self.first}{self.second}{self.third}'