Skip to content

Instantly share code, notes, and snippets.

@yoshapihoff
yoshapihoff / mysql-docker.sh
Created April 3, 2019 14:38 — forked from spalladino/mysql-docker.sh
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE
@yoshapihoff
yoshapihoff / sqlalchemy_example.py
Created January 28, 2019 08:30 — forked from ronreiter/sqlalchemy_example.py
SQLAlchemy Example
from sqlalchemy import Column, Integer, String, ForeignKey, create_engine
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship, backref, sessionmaker, joinedload
# For this example we will use an in-memory sqlite DB.
# Let's also configure it to echo everything it does to the screen.
engine = create_engine('sqlite:///:memory:', echo=True)
# The base class which our objects will be defined on.
Base = declarative_base()
@yoshapihoff
yoshapihoff / binary_search.php
Created March 10, 2017 11:49
Binary search by array element
<?php
function search_by_column_value($search_val, $arr, $column = 'ID')
{
if (empty($search_val))
{
return false;
}
return binary_search($search_val, $arr, $column);
}
@yoshapihoff
yoshapihoff / 0_reuse_code.js
Created October 23, 2016 00:43
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
public class CacheComponent: MonoBehaviour
{
Transform thisTransform;
public new Transform transform
{
get
{
if (thisTransform == null)
{
thisTransform = base.transform;
using UnityEngine;
using System.Collections;
public class Singleton<Instance> : MonoBehaviour where Instance : Singleton<Instance>
{
public static Instance Inst;
public bool isPersistant;
public virtual void Awake()
{
@yoshapihoff
yoshapihoff / CrosshairAiming.cs
Last active October 21, 2016 06:58
Normal 2d game crosshair rotation by mouse
using UnityEngine;
public class AimingExample : MonoBehaviour
{
public Transform Crosshair;
private Transform ThisTransform;
void Start ()
{
ThisTransform = GetComponent<Transform> ();