Skip to content

Instantly share code, notes, and snippets.

View nasal's full-sized avatar

Rudi Kovač nasal

View GitHub Profile
@nasal
nasal / graphql.md
Last active October 24, 2018 12:05
GraphQL for idiots

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

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 January 12, 2017 10:35 — forked from engelfrost/LICENSE
Fake localStorage. Useful for Safari Private Browsing and browsers that don't implement localStorage.
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:
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: []
@nasal
nasal / .vimrc
Last active August 11, 2016 18:22
" 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 January 6, 2015 15:49
C#: Get current method name
System.Reflection.MethodBase.GetCurrentMethod().Name
@nasal
nasal / thread.cs
Created January 6, 2015 15:44
C#: Simple thread
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 October 9, 2018 22:57
XAML: Fade in and out animation
<!-- 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 January 6, 2015 11:48
C#: Fade out animation
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 October 6, 2014 10:08
PHP: Force SSL
<?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();