Skip to content

Instantly share code, notes, and snippets.

View nasal's full-sized avatar

Rudi Kovač nasal

View GitHub Profile
@nasal
nasal / mb_ucwords.php
Created March 6, 2014 10:06
PHP: mb_ucwords
<?php
if (!function_exists('mb_ucwords'))
{
function mb_ucwords($str)
{
return mb_convert_case($str, MB_CASE_TITLE, "UTF-8");
}
}
?>
@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

@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>

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:
@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
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 / wp8-responsive.js
Created January 17, 2014 09:53
JS: WP8 IE responsive hack
if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
var msViewportStyle = document.createElement("style");
msViewportStyle.appendChild(
document.createTextNode(
"@-ms-viewport{width:auto!important}"
)
);
document.getElementsByTagName("head")[0].
appendChild(msViewportStyle);
}
@nasal
nasal / .htaccess
Created January 15, 2014 07:17
Apache: remove .php extension from url
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.php -f
RewriteRule ^(.*)$ $1.php
@nasal
nasal / changepiece.php
Created December 25, 2013 15:27
PHP: Change a piece of the URL
function changepiece($parameter, $value)
{
$params = array();
$output = "?";
$firstRun = true;
foreach($_GET as $key=>$val)
{
if($key != $parameter)
{
if(!$firstRun)