Skip to content

Instantly share code, notes, and snippets.

View anytizer's full-sized avatar

Bimal Poudel anytizer

View GitHub Profile
@anytizer
anytizer / ConfigurationsController.cs
Last active March 20, 2022 20:06
Angular CORS enabled web api server in C# .net 6
using dtos;
using Microsoft.AspNetCore.Mvc;
namespace web.api
{
[Route("api/[controller]")]
[ApiController]
public class ConfigurationsController : ControllerBase
{
[HttpGet]
@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 / 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 / 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 / pdo-mysql.php
Last active April 22, 2020 01:33
Object Oriented PDO MySQL Example
<?php
header("Content-Type: text/plain; charset=utf-8");
ini_set("default_charset", "UTF-8");
mb_internal_encoding("UTF-8");
mb_http_output("UTF-8");
abstract class database
{
protected $pdo = null;
@anytizer
anytizer / color-clipboard.php
Last active February 9, 2018 15:26
Color Picker using clipboard.js
<!-- https://raw.githubusercontent.com/zenorocha/clipboard.js/master/dist/clipboard.min.js -->
<script src="clipboard.min.js"></script>
<script>
function copyc(color, element)
{
new Clipboard('.block', {
container: element
});
}
</script>
@anytizer
anytizer / system-command.cs
Last active February 9, 2018 15:26
Command line execution and output in C#
string args = "-f edit.php";
string file = "php.exe";
ProcessStartInfo info = new ProcessStartInfo();
info.FileName = file;
info.Arguments = args;
info.RedirectStandardOutput = true;
info.RedirectStandardError = true;
info.UseShellExecute = false;
info.CreateNoWindow = true; // flashing screen hidden