Skip to content

Instantly share code, notes, and snippets.

View anytizer's full-sized avatar

Bimal Poudel anytizer

  • Canada
View GitHub Profile
@anytizer
anytizer / dbcontext.cs
Last active June 17, 2022 06:49
C# SQLite Entity Framework
using configs;
using databases.models;
using Microsoft.EntityFrameworkCore;
namespace databases.contexts
{
public class ProjectContext : DbContext
{
public DbSet<CompanyModel>? companies { get; set; }
public DbSet<InvoiceModel>? invoices { get; set; }
@anytizer
anytizer / invoice.html
Created October 29, 2021 16:28
AngularJS Invoice JSON ($http example)
<!doctype html>
<html>
<head>
<title>Invoice</title>
<script src="angular.min.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="w3.css" />
</head>
<body ng-app="ReportsApp" ng-controller="InvoiceController">
<div>
@anytizer
anytizer / regex.cs
Created October 19, 2021 18:04
Regular Expression pattern match
int nominator = Nominiators.FOUR;
int denominator = Denominators.FOUR;
int tempo = Tempos.ONEFOURTY;
FileInfo fi = new FileInfo(filename);
string pattern = @"^filename-(\d+)-(\d+)-(\d+)\.txt$";
Regex re = new Regex(pattern);
Match chunks = re.Match(fi.Name);
if(chunks.Groups.Count == 4)
@anytizer
anytizer / SampleDTOs.cs
Last active April 28, 2020 17:26
Convert SQLite database into Data Transfer Object for C#.
namespace dtos {
public class EmployeesDTO {
public string employee_id { get; set; }
public string employee_code { get; set; }
public string employee_title { get; set; }
public string employee_name { get; set; }
public string employee_email { get; set; }
public string employee_phone { get; set; }
public string employee_address { get; set; }
public string is_visible { get; set; }
@anytizer
anytizer / fetch.cs
Created April 26, 2020 15:15
RestSharp example
RestClient client = new RestClient(configs.login);
RestRequest request = new RestRequest("/api/login/", DataFormat.Json);
request.AddHeader("Content-Type", "application/json");
request.AddJsonBody(login);
IRestResponse response = client.Execute(request, Method.POST);
SuccessDTO attempt = JsonConvert.DeserializeObject<SuccessDTO>(response.Content);
return attempt.status;
@anytizer
anytizer / function.py
Last active April 6, 2020 17:10
Create an SQLite function: GUID()
import sqlite3
import uuid
"""
CREATE TABLE "users" (
"user_id" TEXT NOT NULL,
"user_email" TEXT NOT NULL UNIQUE,
"user_password" TEXT NOT NULL,
PRIMARY KEY("user_id")
);
@anytizer
anytizer / smb.conf
Created April 4, 2020 16:27
SAMBA Configuration
[web]
comment = PHP Web Directory
path = /var/www/html
browseable = yes
create mask = 0777
directory mask = 0777
follow symlinks = yes
only guest = no
public = no
wide links = yes
@anytizer
anytizer / composer.json
Last active September 29, 2018 01:47
Eloquent database without laravel
{
"require": {
"anytizer/guid.php": "dev-master",
"illuminate/database": "^5.7",
"illuminate/events": "^5.7",
"illuminate/container": "^5.7",
"illuminate/contracts": "^5.6",
}
}
@anytizer
anytizer / cors.php
Created September 15, 2018 19:03
CORS with PHP
<?php
if($_SERVER["REQUEST_METHOD"] === "OPTIONS")
{
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: GET, POST");
header("Access-Control-Allow-Headers: X-Protection-Token");
die();
}
@anytizer
anytizer / paint-line.cs
Created March 3, 2018 15:58
Line draw in WinForms
// paint handler
private void fForm_Paint(object sender, PaintEventArgs e)
{
Pen redPen = new Pen(Color.Red, 1.0F);
PointF p1 = new PointF(20.0F, 50.0F);
PointF p2 = new PointF(200.0F, 50.0F);
e.Graphics.DrawLine(redPen, p1, p2);
}