Skip to content

Instantly share code, notes, and snippets.

View ansarizafar's full-sized avatar

Zafar Ansari ansarizafar

View GitHub Profile
(function (history, trackingId, options) {
const generateId = () => {
return '_' + Math.random().toString(36).substr(2, 9);
};
const getId = () => {
if (!localStorage.cid) {
localStorage.cid = generateId()
}
return localStorage.cid;
};
@ansarizafar
ansarizafar / example.js
Created April 24, 2019 08:00 — forked from johanalkstal/example.js
Basic Svelte Store Routing
/**
* Basic example of routerless store based routing.
* To understand what is going on check out
* https://svelte.dev/tutorial/writable-stores
* https://www.npmjs.com/package/feather-route-matcher
*/
// stores.js
@ansarizafar
ansarizafar / HighlightedLink.svelte
Created September 16, 2019 04:18 — forked from jcollum/HighlightedLink.svelte
Svelte + Sapper highlighted link (component that is aware of current url)
Future main() async {
final Iterable<Locale> supportedLocales = [Locale('en'), Locale('ar')];
await Langs.init(supportedLocales: supportedLocales, loadDeviceLanguage: true);
runApp(MyApp(supportedLocales: supportedLocales));
print(Langs.string('sample.item.name'));
print(Langs.string('name'));
}
@ansarizafar
ansarizafar / curved_appbar.dart
Created November 29, 2019 02:35 — forked from mjohnsullivan/curved_appbar.dart
A curved Flutter AppBar where widgets scroll nicely beneath the curved portion
import 'package:flutter/material.dart';
void main() => runApp(
MaterialApp(home: MyHomePage()),
);
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
const curveHeight = 50.0;
void main() {
runApp(_SwitchingThemeApp());
}
/// Properties that help me keep track of the example being run.
bool _useMaterial = false;
class _SwitchingThemeApp extends StatefulWidget {
@override
_SwitchingThemeAppState createState() => _SwitchingThemeAppState();
@ansarizafar
ansarizafar / icon_gradient.dart
Created December 11, 2019 03:51 — forked from mjohnsullivan/icon_gradient.dart
Apply a color gradient to an icon in Flutter
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
body: Center(
@ansarizafar
ansarizafar / transitions_fun.dart
Created January 9, 2020 09:11 — forked from slightfoot/transitions_fun.dart
Fun with Route Animations - by Simon Lightfoot - #HumpDayQandA - 8th Janurary 2020
// MIT License
//
// Copyright (c) 2019 Simon Lightfoot
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
@ansarizafar
ansarizafar / AutoMigration.cs
Created April 2, 2020 04:46 — forked from lakeman/AutoMigration.cs
Automatic database migration with EF Core 3.0
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations.Design;
using Microsoft.EntityFrameworkCore.Migrations.Operations;
using Microsoft.EntityFrameworkCore.Storage;
@ansarizafar
ansarizafar / AutoMigration.cs
Created April 2, 2020 04:46 — forked from lakeman/AutoMigration.cs
Automatic database migration with EF Core 3.0
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Design.Internal;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations.Design;
using Microsoft.EntityFrameworkCore.Migrations.Operations;
using Microsoft.EntityFrameworkCore.Storage;