Skip to content

Instantly share code, notes, and snippets.

class A(object):
def foo(self, x):
print "regular foo() method: %s %s" %(self, x)
@classmethod
def cls_foo(cls, x):
print "class method cls_foo(): %s %s" %(cls, x)
@salmanwahed
salmanwahed / smwvimrc
Last active March 9, 2016 07:09
vimrc file
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" TODO: this may not be in the correct place. It is intended to allow overriding <Leader>.
" source ~/.vimrc.before if it exists.
if filereadable(expand("~/.vimrc.before"))
source ~/.vimrc.before
endif
@salmanwahed
salmanwahed / api.py
Created May 1, 2015 15:23
REST Api with Flask-Restful and MongoDB
# -*- coding: utf-8 -*-
from flask import Flask, jsonify, url_for, redirect, request
from flask_pymongo import PyMongo
from flask_restful import Api, Resource
app = Flask(__name__)
app.config["MONGO_DBNAME"] = "students_db"
mongo = PyMongo(app, config_prefix='MONGO')
APP_URL = "http://127.0.0.1:5000"
@salmanwahed
salmanwahed / apitest.py
Last active August 29, 2015 14:20
testing rest api
In [1]: from requests import get, post, put, delete
In [2]: get("http://127.0.0.1:5000/api")
In [3]: data = {"name": "Example Name", "registration": "123433199", "department": "cse"}
In [4]: post("http://127.0.0.1:5000/api", json=data).json()
In [5]: put("http://127.0.0.1:5000/api/123433199", json={"website": "www.example.com"}).json()
In [6]: delete("http://127.0.0.1:5000/api/123433199").json()
@salmanwahed
salmanwahed / smwbashrc
Created November 17, 2015 15:13
.bashrc file backup
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
#include<stdio.h>
int main(){
int num;
while(scanf("%d", &num)==1){
if(num % 2 == 0){
printf("Even\n");
}
else{
printf("Odd\n");
@salmanwahed
salmanwahed / string_reverse.c
Last active November 7, 2016 19:21
Reversing a string.
# include<stdio.h>
# include<string.h>
# define SWAP(a, b) {char tmp; tmp=a; a=b; b=tmp;}
int main(){
char str[80];
int len, i;
scanf("%[^\n]*c", str);
@salmanwahed
salmanwahed / CryptoUtil.java
Created February 10, 2020 07:27
AES Encryption and Decryption funcition for basic usage.
import java.security.AlgorithmParameters;
import java.security.NoSuchAlgorithmException;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
import java.util.Base64;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.PBEKeySpec;
@salmanwahed
salmanwahed / Configure_IPsec-L2TP_VPN_Clients.md
Last active September 27, 2022 04:43
This gist is copied from ttps://github.com/hwdsl2/setup-ipsec-vpn/blob/master/docs/clients.md

Configure IPsec/L2TP VPN Clients

Read this in other languages: English, 简体中文.

Note: You may also connect using IKEv2 (recommended) or IPsec/XAuth mode.

After setting up your own VPN server, follow these steps to configure your devices. IPsec/L2TP is natively supported by Android, iOS, OS X, and Windows. There is no additional software to install. Setup should only take a few minutes. In case you are unable to connect, first check to make sure the VPN credentials were entered correctly.


  • Platforms
@salmanwahed
salmanwahed / tds-privacy-policy.md
Created December 21, 2021 04:12
TDN News APP privacy policy

Privacy Policy

Salman Wahed built the TDS News app as a Free app. This SERVICE is provided by Salman Wahed at no cost and is intended for use as is.

This page is used to inform visitors regarding my policies with the collection, use, and disclosure of Personal Information if anyone decided to use my Service.

If you choose to use my Service, then you agree to the collection and use of information in relation to this policy. The Personal Information that I collect is used for providing and improving the Service. I will not use or share your information with anyone except as described in this Privacy Policy.

The terms used in this Privacy Policy have the same meanings as in our Terms and Conditions, which are accessible at TDS News unless otherwise defined in this Privacy Policy.