Skip to content

Instantly share code, notes, and snippets.

@abdullah353
abdullah353 / 0_reuse_code.js
Created February 7, 2014 12:00
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
import static com.googlecode.javacv.cpp.opencv_core.*;
import static com.googlecode.javacv.cpp.opencv_highgui.*;
import static com.googlecode.javacv.cpp.opencv_imgproc.*;
public class circleDetection{
public static void main(String[] args){
IplImage src = cvLoadImage("img2.png");
IplImage gray = cvCreateImage(cvGetSize(src), 8, 1);
cvCvtColor(src, gray, CV_BGR2GRAY);
<?php
Illuminate\Routing\UrlGenerator
__construct(RouteCollection $routes, Request $request) Both parameter ar from Symfony
full() // Get the full URL for the current request.
current() // Get the current URL for the request.
previous() // Get the URL for the previous request.
to($path, $parameters = array(), $secure = null) // Generate a absolute URL to the given path.
secure($path, $parameters = array()) // Generate a secure, absolute URL to the given path.
asset($path, $secure = null) // Generate a URL to an application asset.
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,

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 / 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 / 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
@abdullah353
abdullah353 / websocket.js
Created December 27, 2021 16:45 — forked from bearice/websocket.js
My own (and dirty) implementation of WebSocket-Protocol-Version-8 on nodejs
var crypto = require('crypto');
var WSProtocolHandler = {
"8":{
handshake:function(req,socket,head,callback){
var key = req.headers["sec-websocket-key"];
if(!key)return false;
key += "258EAFA5-E914-47DA-95CA-C5AB0DC85B11";
var sha1 = crypto.createHash('sha1');
sha1.update(key);