Skip to content

Instantly share code, notes, and snippets.

Yaser Almasri yalmasri

Block or report user

Report or block yalmasri

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@yalmasri
yalmasri / delete-channel-messages.js
Created Jun 25, 2018 — forked from firatkucuk/delete-slack-messages.js
Deletes slack public/private channel messages.
View delete-channel-messages.js
var https = require('https');
// CONFIGURATION #######################################################################################################
var token = 'SLACK TOKEN';
var channel = 'CHANNEL ID';
var privateChannel = false;
var delay = 300; // delay between delete operations in millisecond
// GLOBALS #############################################################################################################
View openpay.rb
url = "https://sandbox-api.openpay.mx/v1/#{ENV['OPENPAY_MERCHANT_ID']}/webhooks"
hook = {
url: URL_TO_MY_CONTROLLER,
user: 'USER',
password: 'PASSWORD',
event_types: [
'charge.refunded',
'charge.failed',
'charge.cancelled',
'charge.created',
View ios10LocalNotifications.swift
func showPushNotification(title: String, details: String) {
if #available(iOS 10.0, *) {
let interval = TimeInterval(1)
let trigger = UNTimeIntervalNotificationTrigger(timeInterval: interval, repeats: false)
let content = UNMutableNotificationContent()
content.title = title
content.body = details
let req = UNNotificationRequest(identifier: "localPushNotification", content: content, trigger: trigger)
let center = UNUserNotificationCenter.current()
center.getNotificationSettings(completionHandler: { settings in
@yalmasri
yalmasri / ViewController.swift
Created Mar 3, 2017
Login form with StoryBoard
View ViewController.swift
import UIKit
class ViewController: UIViewController {
let logoImageView: UIImageView = {
let image = UIImage(named: "logo")
let iv = UIImageView(image: image)
iv.contentMode = .scaleAspectFit
iv.translatesAutoresizingMaskIntoConstraints = false
return iv
View imageDownloadExtension.swift
extension UIImageView {
public func imageFromUrl(urlString: String) {
if let url = NSURL(string: urlString) {
let request = NSURLRequest(URL: url)
let config = NSURLSessionConfiguration.defaultSessionConfiguration()
let session = NSURLSession(configuration: config)
let task = session.dataTaskWithRequest(request, completionHandler: {(data, response, error) in
if let imageData = data as NSData? {
View m_cfdi.rb
# Primero, tienes que poner el Timezone de tu app.
# debes tener el archivo .cer y .pem de SAT.
# esta clase la puedes guardar en tu carpeta lib.
class Invoice
def initialize(args = {})
@invoice = args[:invoice] # ex una class que debes tener in tu app.
@cer = args[:cer] # la ruta para el archivo .cer
@pem = args[:pem] # la ruta para el archivo .pem.
@pass = args[:password] # contraseña del archivo pem. la contraseña de SAT.
invoice_cfdi
@yalmasri
yalmasri / Invoice.rb
Last active Apr 23, 2016
Invoice class for MCFDI
View Invoice.rb
class MyInvoice
def folio
# folio de la factura, lo especifica tu sistema.
'1234'
end
def series
# la serie de la factura, la especifica tu sistema.
'MS'
end
@yalmasri
yalmasri / gist:0cfa5ba6ee42ab594ed9
Created Mar 5, 2016 — forked from trcarden/gist:3295935
Rails 3.2.7 SSL Localhost (no red warnings, no apache config)
View gist:0cfa5ba6ee42ab594ed9
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@yalmasri
yalmasri / web-server.rb
Created Feb 6, 2016 — forked from Integralist/web-server.rb
Create basic Web Server in Ruby (using WEBrick)
View web-server.rb
#!/usr/bin/env ruby
require "webrick"
=begin
WEBrick is a Ruby library that makes it easy to build an HTTP server with Ruby.
It comes with most installations of Ruby by default (it’s part of the standard library),
so you can usually create a basic web/HTTP server with only several lines of code.
The following code creates a generic WEBrick server on the local machine on port 1234,
@yalmasri
yalmasri / clear_selection.js
Last active Feb 5, 2016 — forked from mudassir0909/clear_selection.js
Selectize plugin which gives an option to clear selection
View clear_selection.js
Selectize.define( 'clear_selection', function ( options ) {
var self = this;
var title = options.title || 'Clear Selection';
//Overriding because, ideally you wouldn't use header & clear_selection simultaneously
self.plugins.settings.dropdown_header = {
title: title
};
this.require( 'dropdown_header' );
You can’t perform that action at this time.