Skip to content

Instantly share code, notes, and snippets.

View thePunderWoman's full-sized avatar

Jessica Janiuk thePunderWoman

View GitHub Profile
// Get the parent categories
List<APICategory> parent_cats = CURTAPI.GetParentCategories();
foreach (APICategory parent in parent_cats) {
List<APICategory> subs = CURTAPI.GetSubCategories(parent.catID);
parent.sub_categories = subs;
}
ViewBag.parent_cats = parent_cats;
@thePunderWoman
thePunderWoman / prepared_stmts.go
Last active December 16, 2015 08:39
Prepared Statements with go routines to run the preparation method
// Prepare all MySQL statements
func PrepareAll() error {
UnPreparedStatements := make(map[string]string, 0)
UnPreparedStatements["authenticateUserStmt"] = "select * from user where username=? and encpassword=? and isActive = 1"
UnPreparedStatements["getUserByIDStmt"] = "select * from user where id=?"
UnPreparedStatements["getUserByUsernameStmt"] = "select * from user where username=?"
UnPreparedStatements["getUserByEmailStmt"] = "select * from user where email=?"
UnPreparedStatements["allUserStmt"] = "select * from user"
Image i = null;
int tries = 0;
while (i == null) {
try {
i = Image.FromFile(server.MapPath(file));
} catch {
// image failed to map
}
tries++;
if (tries >= 10) {
@thePunderWoman
thePunderWoman / gist:5040119
Created February 26, 2013 17:01
SQL Variable usage
USE CurtDev;
GO
DECLARE @id AS int;
--Create new ContentID for every T-Connector part in the Content table
--use last inserted identity value as variable, id
INSERT INTO Content(text, cTypeID)
VALUES ('Simple plug and play design eliminates the need for cutting or splicing', 2);
SET @id = (SELECT @@IDENTITY);
GO
@thePunderWoman
thePunderWoman / gist:5033941
Created February 25, 2013 22:30
Theme sql
CREATE TABLE Theme (
ID int IDENTITY(1,1) PRIMARY KEY NOT NULL,
name varchar(255) NULL,
active bit NOT NULL,
dateAdded datetime NOT NULL
)
GO
CREATE TABLE ThemeFileType (
ID int IDENTITY(1,1) PRIMARY KEY NOT NULL,
@thePunderWoman
thePunderWoman / gist:5032810
Created February 25, 2013 20:08
Integrated GetLatestPartsJson
parts = (from p in db.Parts
join ci in db.CartIntegrations on p.partID equals ci.partID
join cu in db.Customers on ci.custID equals cu.customerID
join c in db.Classes on p.classID equals c.classID into ClassTemp
from c in ClassTemp.DefaultIfEmpty()
where p.featured == true && statuslist.Contains(p.status) && cu.customerID.Equals(customerID) && ci.custPartID > 0
orderby p.dateModified descending
select new APIPart {
partID = p.partID,
custPartID = ci.custPartID,
use CurtDev;
select bv.YearID, ma.MakeName, mo.ModelName, sm.SubmodelName,
(select GROUP_CONCAT(ca.value) as combined
from VehicleConfigAttribute vca
inner join ConfigAttribute ca ON vca.AttributeID = ca.ID
where vca.ID in (select vca1.AttributeID FROM VehicleConfigAttribute vca1 where vca1.VehicleConfigID = v.ConfigID)
) as Config
from BaseVehicle bv
join vcdb_Vehicle v on bv.ID = v.BaseVehicleID
context.MapRoute(
"v2API2",
"v2/{action}/{id}",
new { controller = "v2", id = UrlParameter.Optional }
);
context.MapRoute(
"ordersAPI",
"orders/{action}/{id}",
new { controller = "orders", id = UrlParameter.Optional }
routes.MapRoute(
name: "Mount",
url: "HitchLookup/Mount/{mount}",
defaults: new { controller = "HitchLookup", action = "Mount", mount = "" }
);
routes.MapRoute(
name: "Year",
url: "HitchLookup/Mount/{mount}/Year/{year}",
defaults: new { controller = "HitchLookup", action = "Year", year = "", mount = "" }
routes.MapRoute(
name: "NameOfRoute",
url: "v2/{action}/{id}",
defaults: new { controller = "v2", id = UrlParameter.Optional },
constraints: null,
namespaces: new[] { "App.Areas.Blah.Controllers" }
);