Skip to content

Instantly share code, notes, and snippets.

View mantaskaveckas's full-sized avatar
🏠
Working from home

Mantas Kaveckas mantaskaveckas

🏠
Working from home
View GitHub Profile
@mantaskaveckas
mantaskaveckas / SortFilter.cs
Created December 20, 2023 11:00
EF CRUD sorting/filtering
// Updated Generic BaseController
[ApiController]
[Route("api/[controller]")]
public class BaseController<TEntity> : ControllerBase where TEntity : BaseEntity
{
private readonly YourDbContext _context;
public BaseController(YourDbContext context)
{
_context = context;
@mantaskaveckas
mantaskaveckas / Stuff.cs
Created December 20, 2023 10:56
EF entity CRUD
// BaseEntity for common properties
public abstract class BaseEntity
{
public int Id { get; set; }
// Add other common properties if needed
}
// Example entities
public class Invoice : BaseEntity
{
@mantaskaveckas
mantaskaveckas / unionMerge.d.ts
Created December 20, 2022 10:27
TypeScript Union Merge
type CommonKeys<T extends object> = keyof T;
type AllKeys<T> = T extends any ? keyof T : never;
type Subtract<A, C> = A extends C ? never : A;
type NonCommonKeys<T extends object> = Subtract<AllKeys<T>, CommonKeys<T>>;
type PickType<T, K extends AllKeys<T>> = T extends { [k in K]?: any }
? T[K]
/**
*
* Strings
*
* .split()
* .toLowercase()
* .substring()
* .startsWidth()
*/
const describe = (description, callback) => {
console.log(description);
callback();
};
const it = (message, callback) => describe(` ${message}`, callback);
const matchers = expression => ({
toBe: assertion => {
if (expression === assertion) {
import React, { Component } from 'react';
// Webkit or not, here I come, you can't hide 🎶
const transformProperty = (() => {
const style = document.documentElement.style;
if (typeof style.transform == 'string') {
return 'transform';
}
return 'WebkitTransform';
})();
(ns todomvc.core
(:require [reagent.core :as r]))
(defonce todos (r/atom (sorted-map)))
(defonce counter (r/atom 0))
(defn add-todo [text]
(let [id (swap! counter inc)]
(swap! todos assoc id {:id id :title text :done false})))
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>TO-DO List</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
@mantaskaveckas
mantaskaveckas / checkbox.js
Created June 3, 2015 12:53
Custom HTML checkbox toggle
$('label').on('click', function() {
$(this).siblings('input').attr('checked', function(index, attr) {
return attr == 'checked' ? null : 'checked';
});
});
@mantaskaveckas
mantaskaveckas / _remove-appearance.scss
Created May 27, 2015 11:49
Simple Sass @mixin to remove default appearance for Twitter Bootstrap elements
/*
* Simple Sass @mixin to remove default
* appearance for Twitter Bootstrap elements
*/
@mixin remove-appearance {
&, &:hover, &:focus {
-webkit-appearance: none;
text-decoration: none;
outline: 0;