Skip to content

Instantly share code, notes, and snippets.

// operator-overloading.cpp : Defines the entry point for the Operator Overloading application.
//
#include <cstdlib>
#include <iostream>
using namespace std;
class Nums{
private:
int x, y, z;
@umayr
umayr / generic-pdo-prepare-statement.php
Created April 22, 2014 07:48
Generic PDO Prepare Statement Function
function insert($table, $data)
{
$q = 'insert into ' . $table . ' values(';
for ($i = 0; $i < count($data); $i++) {
$q .= ($i == 0) ? '?' : ',?';
}
$q .= ');';
$dsn = 'mysql:host=' . DBHOST . ';dbname=' . DBNAME;
try {
$pdo = new PDO($dsn, DBUSER, DBPASS);
using System.Security.Cryptography;
using System.Text;
namespace Snippets
{
public static class SHA1Util
{
/// <summary>
/// Compute hash for string encoded as UTF8
/// </summary>
@umayr
umayr / promise.js
Last active July 10, 2017 06:29
Promise API example in native javascript
function getGithubUserInfo(username) {
return new Promise(function (resolve, reject) {
// Do the usual XHR stuff
var url = "https://api.github.com/users/" + username;
var req = new XMLHttpRequest();
req.open('GET', url);
req.onload = function () {
@umayr
umayr / script.sh
Last active August 29, 2015 14:04
How to install NVIDIA drivers on Dell Inspiron 15R N5110 laptop system with dual Intel/Nvidia graphics processors.
#!/bin/bash
## Removing current Nvidia installation.
sudo apt-get purge nvidia*
sudo apt-get purge bumblebee*
sudo apt-get update
sudo apt-get dist-upgrade
## Installing Kernel header if didn't already
@umayr
umayr / Makefile
Created July 26, 2014 17:40 — forked from border/Makefile
include $(GOROOT)/src/Make.inc
GOFMT=gofmt -spaces=true -tabindent=false -tabwidth=4
all:
$(GC) jsontest.go
$(LD) -o jsontest.out jsontest.$O
format:
$(GOFMT) -w jsontest.go
<html>
<head>
<title>Eventizer Document</title>
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<style>
ul > li {
padding: 5px 0;
}
</style>
package twitterfindname
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"strings"
)
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"strings"
)
@umayr
umayr / iife.js
Created September 5, 2014 12:24
IIFE.
// First way:
(function(){
// code here
})();
// Second way:
(function(){
// code here
}).call(this);