Skip to content

Instantly share code, notes, and snippets.

View bobagold's full-sized avatar
💁‍♂️
Working with dart+flutter

Vladimir Goldobin bobagold

💁‍♂️
Working with dart+flutter
View GitHub Profile
@bobagold
bobagold / richtextparse.dart
Last active November 18, 2021 12:30
Parse string to rich text
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
@bobagold
bobagold / main.dart
Created July 1, 2021 09:38
Flutter cards example using Stack
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
home: HomeScreen(),
),
);
}
@bobagold
bobagold / shake_widget.dart
Created June 5, 2020 10:01
Shake any widget in flutter
import 'package:flutter/material.dart';
@immutable
class ShakeWidget extends StatelessWidget {
final Duration duration;
final double deltaX;
final Widget child;
final Curve curve;
const ShakeWidget({
@bobagold
bobagold / main.dart
Created April 24, 2020 23:51
latin_squares_game
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
@bobagold
bobagold / pureFlutterExample.dart
Last active October 28, 2019 16:13
example of pure widgets in flutter
import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:redux/redux.dart';
void main() => runApp(ExampleApp());
// <framework-specific part>
typedef MetaBuilder<ViewModel> = Widget Function(ViewModelBuilder<ViewModel>);
int counterReducer(int state, dynamic action) =>
state + (action is int ? action : 0);
@bobagold
bobagold / example.js
Last active June 28, 2017 16:00
how to change type of _id field in an existing mongo collection from ObjectId to String with the same value
// assuming the collection name is translations
db.translations.find({_id: {$type: 7}}).forEach((r) => {const n = Object.assign({}, r, {_id: r._id.str}); db.translations.remove(r); db.translations.save(n);})
cat > alice.js <<EOT
var public = require('./public');
public.message = 'Hi Bob';
EOT
cat > public.js <<EOT
module.exports = {};
EOT
cat > bob.js <<EOT
var public = require('./public');
console.log(public.message);
function httpProxy($request, $upstream, Closure $callback = null)
{
$requestHeaders = $request['headers'];
unset($requestHeaders['Host'], $requestHeaders['Connection']);
$requestHeaders = stringifyHeaderPairs($requestHeaders);
$ch = curl_init($upstream . $request['uri']);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_HEADER, 1);
@bobagold
bobagold / gist:0977d824b284dfd28574
Created December 15, 2014 11:54
lytdybr (common.gypi, решение внутри)
устанавлиаваю npm пакеты, уже кучу установил, а потом при попыттке установить почти на любой пакет получаю ошибку gyp: /usr/share/node/common.gypi not found ... while reading includes of binding.gyp
гуглю
советуют установить sudo npm -g install node-gyp
не помогает
гуглю
советуют обновиться
не помогает
гуглю
советуют прописать пути
не помогает
@bobagold
bobagold / PHPUnitTest.php
Created August 18, 2014 07:47
PHPUnit makes me crazy
<?php
class PHPUnitTest extends \PHPUnit_Framework_TestCase
{
/**
* output of this test would be
* <cite>
* Failed asserting that 'cat does not have black fur' does not contain "cat does not have black fur".
* </cite>
* this is due to bad usage of PHPUnit_Framework_Constraint_Not::negate()