Skip to content

Instantly share code, notes, and snippets.

@stegrams
stegrams / index.html
Last active October 27, 2015 22:51
Basic Auth with log out
<!DOCTYPE html>
<html>
<head>
<title>Basic Auth Log Out</title>
</head>
<script type="text/javascript">
if(~document.URL.split('/')[2].search('@'))
// clean url from bad credentials (log:out@)
document.location = document.location.origin
+ document.location.pathname;
@stegrams
stegrams / move.js
Last active May 28, 2016 12:32
Lane action in LaneStore for dragging a note over a note or an empy lane instead of attachToLane. Source: http://survivejs.com/webpack_react/implementing_dnd/
queryIds(searchIds){
let ids = [...searchIds];
return this.lanes.reduce((result, lane, laneIdx) => {
// no more ids
if(!ids.length) return result;
const notes = lane.notes;
const idsIndexOfLane = ids.indexOf(lane.id);
@stegrams
stegrams / move_forof.js
Last active May 28, 2016 12:40
Lane action in LaneStore for dragging a note over a note or an empy lane instead of attachToLane. Source: http://survivejs.com/webpack_react/implementing_dnd/
move({sourceId, targetId}){
const lanes = [];
let sourceCheck, targetCheck;
for(let lane of this.lanes){
if (sourceCheck && targetCheck) {
lanes.push(lane);
continue;
}
@stegrams
stegrams / Turnkey2Vagrant.txt
Last active September 9, 2019 20:49
Convert a Turnkey appliance (https://www.turnkeylinux.org) in to a Vagrant box. This is about VirtualBox and the Laravel flavor but it's expected to work with any debian based Turnkey appliances.
1. Download ova from https://www.turnkeylinux.org/laravel
2. Import ova to VirtualBox.
3. Add an empty optical drive to machine
4. Run the machine and login as root
5. Exec ```apt-get install linux-headers-$(uname -r) build-essential dkms sudo```
6. Insert Guest Additions CD image.
7. Exec ```mkdir /media/cdrom```
8. Exec ```mount /dev/cdrom /media/cdrom/```
9. Exec ```sh /media/cdrom/VBoxLinuxAdditions.run```
10. Create the vagrant user ```adduser vagrant```
@stegrams
stegrams / typed_inherited.dart
Created April 9, 2020 01:22
Question: How do i get the happy face by passing any type parameter to ```Foo``` except ```<dynamic>```
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@stegrams
stegrams / code2CountryEmoji.dart
Last active April 16, 2020 12:11
Pawan Kumar‎'s code sample to turn country id to flag emoji
import 'package:flutter/material.dart';
const int flagOffset = 0x1F1E6;
const int asciiOffset = 0x41;
String codeToCountryEmoji(code) {
final char1 = code.codeUnitAt(0) - asciiOffset + flagOffset;
final char2 = code.codeUnitAt(1) - asciiOffset + flagOffset;
return String.fromCharCode(char1) + String.fromCharCode(char2);
}
@stegrams
stegrams / base64toImageMemory.dart
Created April 17, 2020 15:09
Image not showing. From Let's Flutter with Dart
import 'package:flutter/material.dart';
import 'dart:convert';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@stegrams
stegrams / widgetspan_broken_on_dartpad.dart
Created April 18, 2020 11:43
DartPad issue: WidgetSpan is not showing.
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@stegrams
stegrams / flutter_catalog.dart
Last active May 20, 2020 21:12
X-Wei/flutter_catalog basic demos GUI for ListView study.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Catalog',
home: MyHomePage(title: 'Flutter Catalog'),
@stegrams
stegrams / boxed_letters.dart
Last active April 19, 2020 15:14
Sample of characters inside boxes
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(