Skip to content

Instantly share code, notes, and snippets.

using UnityEngine;using System.Collections;  public class Attackable : MonoBehaviour { public float maxHp; public float currentHp; public Camera mainCamera; public Texture2D hpBarBG; public Texture2D hpBarCurrent;  private float offsetY;  //script will be atached to each GameObject that can suffer dmg. void Start () { //put it on top of the character offsetY=gameObject.collider.bounds.size.y+5; Debug.Log(offsetY); }  void Update () { }  void OnGUI(){ //the hp bar background location on screen Rect rcBg = new Rect(0,0,60,14); //the current HP bar Rect rcCurrent = new Rect(0,0,((currentHp)/maxHp)*56,8);  //the important part : where this object is located in my screen Vector3 point = mainCamera.WorldToScreenPoint(new Vector3( transform.position.x,
using UnityEngine;
public class Follow : MonoBehaviour {
Transform target; //the target to follow
Vector3 offset = Vector3.zero; //the amount to be offset by 
void Update() {
if(target) transform.position = target.position + offset;
}
}
float theta_scale = 0.1; //Set lower to add more points
int size = (2.0 * PI) / theta_scale; //Total number of points in circle.
LineRenderer lineRenderer = gameObject.AddComponent<LineRenderer>();
lineRenderer.material = new Material(Shader.Find("Particles/Additive"));
lineRenderer.SetColors(c1, c2);
lineRenderer.SetWidth(0.2F, 0.2F);
lineRenderer.SetVertexCount(size);
int i = 0;

Magento Snippets

Set all categories to is_anchor 1

Find attribute_id

SELECT * FROM eav_attribute where attribute_code = 'is_anchor'

Update all of them with anchor_id from above (usually is ID 51)

UPDATE `catalog_category_entity_int` set value = 1 where attribute_id = 51
@abdullah353
abdullah353 / Aggregations.js
Created November 1, 2015 16:38
MongoDB Queries
# Not only have we been adding wands, but our users have been adding new ones daily! Let's create a list of all the unique wand makers in our database.
db.wands.aggregate(
{
"$group": {
"_id": "$maker"
}
}
)
@abdullah353
abdullah353 / query_boto3.py
Created December 14, 2016 15:39 — forked from numberoverzero/query_boto3.py
Query on an involved table, using boto3
import arrow
import boto3
import uuid
dynamodb = boto3.client('dynamodb')
some_id = uuid.uuid4()
some_time = arrow.now()
request = {
'ConsistentRead': False,
@abdullah353
abdullah353 / bobp-python.md
Created April 18, 2017 15:15 — forked from sloria/bobp-python.md
A "Best of the Best Practices" (BOBP) guide to developing in Python.

The Best of the Best Practices (BOBP) Guide for Python

A "Best of the Best Practices" (BOBP) guide to developing in Python.

In General

Values

  • "Build tools for others that you want to be built for you." - Kenneth Reitz
  • "Simplicity is alway better than functionality." - Pieter Hintjens
@abdullah353
abdullah353 / .gitlab-ci.yml
Created July 15, 2017 11:20
Basic skeleton of Gitlab CI integration with AWS Lambda for auto deployments.
image: docker:latest
before_script:
- apt-get update -y # Updating the Ubuntu Docker instance.
- python -V # Print out python version for debugging.
- apt install -y zip jq
- pip install awscli --upgrade --user
- export PATH=~/.local/bin:$PATH # Required for awscli.
- aws --version # Print out aws cli version for debugging.
@abdullah353
abdullah353 / better-nodejs-require-paths.md
Created August 12, 2017 18:43 — forked from branneman/better-nodejs-require-paths.md
Better local require() paths for Node.js

Better local require() paths for Node.js

Problem

When the directory structure of your Node.js application (not library!) has some depth, you end up with a lot of annoying relative paths in your require calls like:

var Article = require('../../../models/article');

Those suck for maintenance and they're ugly.

Possible solutions

@abdullah353
abdullah353 / install-htop.sh
Created September 14, 2017 01:07 — forked from alexandrerocco/install-htop.sh
Amazon Linux - Install htop
# update
sudo yum -y update
sudo yum -y upgrade
# enable EPEL6 by changing enabled=0 -> enabled=1
sudo vim /etc/yum.repos.d/epel.repo
# install htop
sudo yum install htop