Skip to content

Instantly share code, notes, and snippets.

View mohamedmansour's full-sized avatar
✔️
Available

Mohamed Mansour mohamedmansour

✔️
Available
View GitHub Profile
@mohamedmansour
mohamedmansour / crawler.js
Created December 6, 2017 04:48
Node Crawler
const cheerio = require('cheerio')
const request = require('request')
const { URL } = require('url')
const async = require('async')
var links = {}
fetchAllLinks('https://crawl.codeferret.net/1.html', links, () => {
let listLinks = Object.keys(links).map(link => {return `"${link}"`})
console.log(`[\n ${listLinks.join(',\n ')}\n ]`)
})
@mohamedmansour
mohamedmansour / alexa-node.js
Created February 18, 2017 11:31
Hackathon - Amazon Alexa Backend using Lambda
var http = require('http');
exports.handler = function (event, context) {
try {
console.log("event.session.application.applicationId=" + event.session.application.applicationId);
if (event.session.new) {
onSessionStarted({requestId: event.request.requestId}, event.session);
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Microsoft.AspNetCore.Html;
using Newtonsoft.Json;
namespace HtmlHelpers
{
/// <summary>
task<GeolocationAccessStatus> geolocationAccessRequestTask(Windows::Devices::Geolocation::Geolocator::RequestAccessAsync());
geolocationAccessRequestTask.then([this](task<GeolocationAccessStatus> accessStatusTask)
{
// Get will throw an exception if the task was canceled or failed with an error
auto accessStatus = accessStatusTask.get();
if (accessStatus == GeolocationAccessStatus::Allowed)
{
// LOG: Waiting for update...
auto geolocator = ref new Windows::Devices::Geolocation::Geolocator();
@mohamedmansour
mohamedmansour / gist:33802d10fcf218e28fc6
Created March 29, 2015 01:04
JavaScript Decruft JSON
// In jQuery the easy thing to do when to decruft json responses if a javascript has:
//
// for (;;); {foo: 'bar'}
//
// Is to decruft it using ajax converters. Example
$.ajaxSetup({
converters: {
"text json": function(result) {
return JSON.parse(result.replace('for (;;);', ''));
@mohamedmansour
mohamedmansour / Animation.xaml
Created July 3, 2014 19:02
Pulse Animation in XAML
<UserControl.Resources>
<Storyboard x:Name="StartAnimation">
<DoubleAnimation RepeatBehavior="Forever" Duration="0:0:1" To="360" Storyboard.TargetProperty="(UIElement.RenderTransform).(CompositeTransform.Rotation)" Storyboard.TargetName="ProgressArc"/>
<DoubleAnimation Duration="0:0:0.5" RepeatBehavior="Forever" AutoReverse="True" From="25" To="35" Storyboard.TargetName="IndicatorRing" Storyboard.TargetProperty="StrokeThickness"/>
<DoubleAnimation Duration="0:0:0.5" RepeatBehavior="Forever" AutoReverse="True" From="350" To="370" Storyboard.TargetName="IndicatorRing" Storyboard.TargetProperty="Height"/>
<DoubleAnimation Duration="0:0:0.5" RepeatBehavior="Forever" AutoReverse="True" From="350" To="370" Storyboard.TargetName="IndicatorRing" Storyboard.TargetProperty="Width"/>
</Storyboard>
</UserControl.Resources>
@mohamedmansour
mohamedmansour / gist:dc0c56820015e7f700e9
Last active August 29, 2015 14:02
Basic Cross Sandbox Communication for iOS 8 Action Extensions
// Append the transfer dom to the document.
var transferDOM = document.createElement('div');
transferDOM.style.display = 'none';
transferDOM.id = 'transferdom';
document.body.appendChild(transferDOM);
function injectScript(fn) {
var script = document.createElement('script');
script.appendChild(document.createTextNode('(' + fn + ')();'));
document.body.appendChild(script);
@mohamedmansour
mohamedmansour / Popup.xaml
Created May 10, 2014 00:14
Example of a popup control in Xaml with nice triangle
<Grid x:Name="LayoutRoot" Background="Transparent" Margin="0,55,0,0">
<Grid Background="White" Margin="0,10,0,0">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Margin="20" Background="Transparent">
<TextBlock Text="Listening" FontSize="36" Margin="0"/>
</StackPanel>
<StackPanel Grid.Row="1" Margin="20" Background="Transparent" VerticalAlignment="Bottom">
@mohamedmansour
mohamedmansour / et-ptemplates-frontend.js
Created November 17, 2012 21:22
Wordpress Webly Autoplay for YouTube
/* <![CDATA[ */
jQuery(document).ready(function() {
jQuery("a[class*=fancybox]").fancybox({
'overlayOpacity' : 0.7,
'overlayColor' : '#000000',
'transitionIn' : 'elastic',
'transitionOut' : 'elastic',
'easingIn' : 'easeOutBack',
'easingOut' : 'easeInBack',
'speedIn' : '700',
@mohamedmansour
mohamedmansour / live_hangout.html
Created July 6, 2012 09:45
Google+ Hangouts On Air Embed
<html>
<!--
// Uses YouTube Live Feeds API:
// https://developers.google.com/youtube/2.0/developers_guide_protocol_retrieving_live_events
//
// Usage:
// 1) Copy paste the code below to your page.
// 2) Remember to replace your YouTube [USER_NAME] in the last script element to your own, for example, DariaMusk
// 3) You can add CSS Style to the first DIV element to make it look pretty and resize it to any size (normal CSS).
//