Skip to content

Instantly share code, notes, and snippets.

View afnanenayet's full-sized avatar

Afnan Enayet afnanenayet

View GitHub Profile
<?php
require("OrganizationHome.php");
require("$OrganizationHome/SessionSpecifics.php");
/*
$ConnectMsg = ConnectToDatabase();
if ($ConnectMsg <> "") {
$_SESSION["MenuMsg"] = "Unable to connect to the database at this time...";
header ("Location: Controller.php");
exit;
}
<?php
require('OrganizationHome.php');
require("$OrganizationHome/SessionSpecifics.php");
if (isset($_SESSION['Authority']) and $_SESSION['Authority'] != '') {
header("Location: Controller.php");
exit;
}
if (!isset($_SESSION["Attempts"])) {
$_SESSION["Attempts"] = 0;
$FirstTime = true;
@afnanenayet
afnanenayet / Demo
Last active August 29, 2015 14:19
Business Server Stuff
/*Items originating from org*/
select ItemId, ItemDescription from Items where ItemOriginalOrgId = 279;
/*Those with roles in org*/
select RoleId, AcctId from Roles where OrgId = 279;
/*Items purchased from org and those who ordered them*/
select Details.DItemId, Details.DItemDescription, Orders.OId, Orders.OAcctId, Orders.OBillTo from Orders join Details on OId=DOId where OAcctId=326 order by DItemId;
def return_max_record(timetable):
'''This function returns the maximum number of possible non-concurrent
recordings from VHS. Input a list with each row formatted:
[start time, end time]'''
for times in timetable:
times.append(times[1] - times[0])
# Maximizing the number
timetable = sorted(timetable, key = lambda x: x[2])
#!/usr/bin/perl
use Cwd; # module for finding the current working directory
$|=1; # turn off I/O buffering
$num_arguments = $#ARGV + 1;
$directory_name = $ARGV[0];
foreach $arg_index (0 .. $num_arguments) {
if ($ARGV[$arg_index] eq "-name") {
@afnanenayet
afnanenayet / valid_cpp_loops.cpp
Last active July 26, 2016 02:59
Different ways to construct the same loop in C++
#include <iostream>
using namespace std;
#ifdef __cplusplus
extern "C" {
#endif
void loop();
#ifdef __cplusplus
@afnanenayet
afnanenayet / args.c
Created July 3, 2017 16:18
Command line arguments activity solution
/*
* atoi - read an integer from each argument,
* and print them to stdout. catch errors.
*
* usage: ./atoi [integer]...
*
* CS50, July 2017
*/
#include <stdio.h>
@afnanenayet
afnanenayet / iter_args.sh
Created July 9, 2017 22:54
An example of how to iterate through command line arguments in shell script
# Iterate through arguments supplied from the command line with
# a loop in Bash script
for arg in "$@"
do
echo "$arg"
done
# Example usage:
# ./iter_args.sh 1 2 3 4 5
@afnanenayet
afnanenayet / gdb_valgrind_example.c
Last active December 17, 2021 21:18
An example program that used to demonstrate how to use GDB/LLDB and Valgrind with the tutorial at http://www.afnan.io/debugging-c-with-gdb-and-valgrind/
/* gdb_valgrind_example.c Afnan Enayet
*
* An example designed to help a user understand how to
* use GDB/LLDB and Valgrind
*
* Functions:
* - init_str: a functions that initializes a string
* to "hello"
*
*/
# Implements a logistic regression with mini-batch gradient descent using tensorflow
# testing with the sklearn moons dataset
import tensorflow as tf
import numpy as np
from datetime import datetime
from sklearn.datasets import make_moons
def get_tb_dir(prefix=None) -> str: