Skip to content

Instantly share code, notes, and snippets.

Rudi Kovač nasal

View GitHub Profile
@nasal
nasal / graphql.md
Last active Oct 24, 2018
GraphQL for idiots
View graphql.md

GraphQL for total noobs

Not sure if I'm that stupid or people are starting to make life harder for everyone. I lost a day to figure stuff out, all while growing a couple more gray hair. I also cursed a lot, and considered quitting programming (again).

Maybe it's just me, maybe I overthink everything. I suppose I though GraphQL was something else. I suppose I expected it to help me write an API faster, but it's not like that. It's easier to query the API, but you still have to code everything on your own to make this possible (like the queries).

There are things like join-monster (example below that generate SQL SELECT queries for you (based on the GraphQL query you throw at it), but apart from that, you are on your own.

4 concepts you need to understand

View keybase.md

Keybase proof

I hereby claim:

  • I am nasal on github.
  • I am skejgo (https://keybase.io/skejgo) on keybase.
  • I have a public key ASAVy5RcZKbSzvdtgTbshKw15AfycClKudfqjlX4eq8qSAo

To claim this, I am signing this object:

@nasal
nasal / LICENSE
Created Jan 12, 2017 — forked from engelfrost/LICENSE
Fake localStorage. Useful for Safari Private Browsing and browsers that don't implement localStorage.
View LICENSE
The MIT License (MIT)
Copyright (c) 2015 Textalk
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:
View ReactNativeListViewReReder.tsx
class Something extends React.Component<{}, {drawerWidth: number, dataSource: any, db: any}> {
constructor(props) {
super(props)
this.state = {
drawerWidth: 0,
dataSource: new ListView.DataSource({
rowHasChanged: (row1, row2) => row1 !== row2 || this.state.drawerWidth != 0
// drawerWidth changing from 0 will force a row re-render
}),
db: []
View .vimrc
" git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
" vim +PluginInstall +qall
" mkdir -p ~/.vim/files/info
" git config --global core.editor /usr/bin/vim
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
@nasal
nasal / current-method.cs
Created Jan 6, 2015
C#: Get current method name
View current-method.cs
System.Reflection.MethodBase.GetCurrentMethod().Name
@nasal
nasal / thread.cs
Created Jan 6, 2015
C#: Simple thread
View thread.cs
new Thread(delegate()
{
Dispatcher.BeginInvoke(new Action(delegate()
{
// Do something in the "main" thread (the thread calling the new thread).
}));
// Do whatever you want.
Thread.Sleep(3000);
@nasal
nasal / fadeinout.xaml
Last active Oct 9, 2018
XAML: Fade in and out animation
View fadeinout.xaml
<!-- Invoke with ((Storyboard)FindResource("FadeInOut")).Begin(ControlName); -->
<ResourceDictionary>
<Storyboard x:Key="FadeInOut">
<!-- If the element has Visibility="Hidden". -->
<ObjectAnimationUsingKeyFrames BeginTime="0:0:0" Storyboard.TargetProperty="Visibility">
<DiscreteObjectKeyFrame KeyTime="0">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
@nasal
nasal / fadeout.cs
Created Jan 6, 2015
C#: Fade out animation
View fadeout.cs
var myControl = ControlName;
var a = new DoubleAnimation
{
From = 1.0,
To = 0.0,
FillBehavior = FillBehavior.Stop,
BeginTime = TimeSpan.FromSeconds(2),
Duration = new Duration(TimeSpan.FromSeconds(0.5))
};
var storyboard = new Storyboard();
@nasal
nasal / ssl.php
Created Oct 6, 2014
PHP: Force SSL
View ssl.php
<?php
if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] !== 'on') {
if(!headers_sent()) {
header("Status: 301 Moved Permanently");
header(sprintf(
'Location: https://%s%s',
$_SERVER['HTTP_HOST'],
$_SERVER['REQUEST_URI']
));
exit();
You can’t perform that action at this time.