Skip to content

Instantly share code, notes, and snippets.

View AhmedAliIbrahim's full-sized avatar
🏠
Working from home

Ahmed A. Ibrahim AhmedAliIbrahim

🏠
Working from home
View GitHub Profile
@saravanak
saravanak / checkouts_controller_decorator.rb
Last active October 9, 2018 18:31
The updated checkouts decorator for working around spree/issue/8569
# app/controllers/spree/api/v1/checkouts_controller_decorator.rb
Spree::Api::V1::CheckoutsController.class_eval do
def update
authorize! :update, @order, order_token
if @order.update_from_params(params, permitted_checkout_attributes, request.headers.env)
if current_api_user.has_spree_role?('admin') && user_id.present?
@order.associate_user!(Spree.user_class.find(user_id))
end
@SergeyLipko
SergeyLipko / RN_flatList_example.js
Created May 29, 2017 18:21
Example of using RN FlatList component with pagination and pull-refreshing
import React from 'react';
import {
View,
Text,
FlatList,
StyleSheet
} from 'react-native';
import { ListItem } from 'react-native-elements';
class Users extends React.Component {
@dschep
dschep / post-merge
Last active July 8, 2020 14:00 — forked from sindresorhus/post-merge
git hook to run a command after `git pull` if a specified file was changed.In this example it's used to run `yarn` if yarn.lock changed.Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
#!/usr/bin/env bash
# MIT © Sindre Sorhus - sindresorhus.com
# git hook to run a command after `git pull` if a specified file was changed
# Run `chmod +x post-merge` to make it executable then put it into `.git/hooks/`.
changed_files="$(git diff-tree -r --name-only --no-commit-id ORIG_HEAD HEAD)"
check_run() {
echo "$changed_files" | grep --quiet "$1" && eval "$2"
import React, { PureComponent } from 'react';
import { StyleSheet, View, TouchableWithoutFeedback, Animated, Easing, Platform } from 'react-native';
import { COLOR, Toolbar, Icon } from '../react-native-material-ui';
const styles = StyleSheet.create({
pageContainer: {
flex: 1,
},
contentContainer: {
@fadhlirahim
fadhlirahim / access_token_helper.rb
Created September 6, 2016 05:07
doorkeeper oauth token in rspec
# assumption
# model user exist
#
module AccessTokenHelper
APP_NAME = "app name".freeze
REDIRECT_URL = "https://host.name/oauth/callback".freeze
def token_scopes(scopes)
app = Doorkeeper::Application.create!(:name => "MyApp", :redirect_uri => REDIRECT_URL)
user = create(:user)
@theorigin
theorigin / SQLServer-APIPost.sql
Last active January 9, 2024 12:10
SQL Server code to POST to an API
DECLARE @Object AS INT;
DECLARE @ResponseText AS VARCHAR(8000);
DECLARE @Body AS VARCHAR(8000) =
'{
"what": 1,
"ever": "you",
"need": "to send as the body"
}'
EXEC sp_OACreate 'MSXML2.XMLHTTP', @Object OUT;
@maxivak
maxivak / Spree: Filter by brand.md
Last active March 16, 2021 01:31
Spree: Filter Products by properties

Fix 'scoped' error for Rails 4

error: undefined method 'scoped' solution:

# config/initializers/scoped.rb
class ActiveRecord::Base
  # do things the modern way and silence Rails 4 deprecation warnings
 def self.scoped(options=nil)

options ? where(nil).apply_finder_options(options, true) : where(nil)

@momolog
momolog / checkout_controller_decorator.rb
Last active January 27, 2024 07:43
add minimum order value to spree orders
Spree::CheckoutController.class_eval do
def ensure_checkout_allowed
check = @order.checkout_allowed?
unless check == true
redirect_to spree.cart_path, :flash => {:error => I18n.t("checkout_allowed_errors.#{check}")}
end
end
end
@elidickinson
elidickinson / max_width_email.html
Created May 6, 2013 15:10
Email Template trick: max-width with outlook
<!--[if mso]>
<center>
<table><tr><td width="580">
<![endif]-->
<div style="max-width:580px; margin:0 auto;">
<p>This text will be centered and constrained to 580 pixels even on Outlook which does not support max-width CSS</p>
</div>
<!--[if mso]>
@jcowhigjr
jcowhigjr / spree-api-rest-examples.md
Created November 5, 2012 23:58
Spree API REST Examples

Products

index of products 25 first

curl -i -H "X-Spree-Token: YOUR_TOKEN_ID" http://0.0.0.0:3000/api/products.json

Show a product

curl -i -H "X-Spree-Token: YOUR_TOKEN_ID" http://0.0.0.0:3000/api/products/706676762.json

Modify a product

curl -i -X PUT -H "X-Spree-Token: YOUR_TOKEN_ID" -d "product[name]=Headphones" http://0.0.0.0:3000/api/products/706676762.json