Skip to content

Instantly share code, notes, and snippets.

@AykutSarac
AykutSarac / csv-parser.ts
Last active December 29, 2023 11:50
Zero dependency CSV parser in TypeScript with generics support
type CSVRow<T> = Record<keyof T, string | number>;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
class CSVParser<T = any> {
private rows: CSVRow<T>[];
private header: (keyof T)[];
constructor(csvData: string) {
this.rows = this.parseCSV(csvData);
this.header = this.rows.length > 0 ? (Object.keys(this.rows[0]) as (keyof T)[]) : [];
@pantaluna
pantaluna / Gruntfile.js
Created April 1, 2016 20:25
Gruntfile.js of bootstrap-4.0.0-alpha.2
grunt - build - control
/*!
* Bootstrap's Gruntfile
* http://getbootstrap.com
* Copyright 2013-2015 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
module.exports = function (grunt) {
'use strict';
@soylent-grin
soylent-grin / Grintfile.js
Created July 24, 2015 08:56
My Gruntfile.js sample template
module.exports = function (grunt) {
"use strict";
// requirements
var fs = require('fs');
var glob = require("glob");
var argv = require('yargs').argv;
var mkdirp = require('mkdirp');
anonymous
anonymous / Default.sublime-theme
Created September 5, 2014 22:13
Sublime Text 2 Default theme file
[
{
"class": "label_control",
"color": [255, 255, 255],
"shadow_color": [24, 24, 24],
"shadow_offset": [0, -1]
},
{
"class": "button_control",
"content_margin": [6, 5, 6, 6],
@hdragomir
hdragomir / sm-annotated.html
Last active March 5, 2024 08:57
The deferred font loading logic for Smashing Magazine. http://www.smashingmagazine.com/
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
// Clamps a block of text to a certain number of lines,
// followed by an ellipsis in Webkit and Blink based browsers
// Reference: http://dropshado.ws/post/1015351370/webkit-line-clamp
@mixin text-clamp($lines: 2, $line-height: false) {
overflow: hidden;
display: -webkit-box;
-webkit-box-orient: vertical;
-webkit-line-clamp: $lines;
// Fallback for non-Webkit browsers
/*
* http://christian-fei.com/tutorials/how-to-lazy-load-disqus-comments/
*
* <div class="comments"></div>
*/
var comments = document.getElementsByClassName('comments')[0],
disqusLoaded = false;
function loadDisqus() {